A few weeks ago I ran this through our own JSON repair tool, in the browser, on our own website:
json
{"id": 22233344455566677788}
It came back as:
json
{"id": 22233344455566676000}
No error. No warning. Just a quietly wrong number, presented as a successful repair.
That number is a made-up snowflake ID, the kind of thing you'd see as a primary key in a distributed system. And our own tool — the one whose entire pitch is "we don't ship plausible-looking but wrong results" — had just silently corrupted it and told the user everything was fine.
Why this happens, and why it's not really a bug in the traditional sense
JSON doesn't distinguish between integers and floats. It just has "number." JavaScript doesn't either — every number, however you write it, ends up as an IEEE 754 double-precision float once JSON.parse gets to it. Doubles can represent integers exactly up to Number.MAX_SAFE_INTEGER (2^53 - 1, which is 16 digits). Past that, the value gets silently r
Discussion
Your thoughts matter!
Your input is valuable—be the first to share it!