The reason is that a number like the above is a 64 bit integer which does not fit into the mantissa of a 64 bit floating point variable (which has approximately 16 digits of precision).
The JSON number type has no length limitation.
The solution would be to treat everything as a string when pretty-formatting.
I happen to work with a service where all IDs have a 1E18 "prefix", which makes the pretty format pretty useless.
An output like
becomes the following after pretty-formatting:
The reason is that a number like the above is a 64 bit integer which does not fit into the mantissa of a 64 bit floating point variable (which has approximately 16 digits of precision).
The JSON number type has no length limitation.
The solution would be to treat everything as a string when pretty-formatting.
I happen to work with a service where all IDs have a 1E18 "prefix", which makes the pretty format pretty useless.