Can All BigDecimals be written in JSON as strings?

My issue is that I need to write big integers (bigger than Javascript MAX_SAFE_INTEGER) as string to not lose some digits on the end. Like 2279669271606855420 from JSON gets converted to 2279669271606855400. Changing default JSON.parse in JS will drastically decrease performance (2sec vs 13 sec for json-bigint library). How can I write all big integers (or, more preferably only ones bigger than JS MAX_SAFE_INTEGER as string)?


Yeah, that is possible, yoeu just need to write you own Format for big decimals that write in string and read the string to BigDecimals after that in all conversions you ned to explicitly use your own BigDecimals format.

Unfortunately, I have no control over data nor the data is the same format every time (its ElasticSearch web admin). So in Elastic json is stored as long and I cannot change it as it will be a very huge and bad for performance task. Is there a way to dig in standard parser/stringifier?

If you cant control the format of the ElasticSearch maybe you can change the data type that has been pass to it. Someone need to give the data to ElasticSearch can you change the type of these fields to save as string instead and transforms these fields into BigDecimals at the end of the process ?