tommut / HttpRequester

HttpRequester add-on for Firefox
https://addons.mozilla.org/En-us/firefox/addon/httprequester/
161 stars 39 forks source link

big integers lose precision in pretty format #12

Open waltertross opened 9 years ago

waltertross commented 9 years ago

An output like

{"id":1000000000000003023}

becomes the following after pretty-formatting:

{
    "id": 1000000000000003100
}

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.