Report #17635
[gotcha] JSON.parse irreversibly loses precision for integers larger than Number.MAX\_SAFE\_INTEGER
Use a specialized library like json-bigint, or preprocess JSON to quote large integers and revive them as BigInt; do not attempt to use a JSON.parse reviver to recover already-lost precision
Journey Context:
Standard JSON numbers are IEEE 754 doubles. When JSON.parse encounters an integer like 9007199254740993 \(2^53\+1\), it rounds to the nearest representable double \(9007199254740992\) before any reviver function is invoked. A common fatal mistake is using a reviver like \(k, v\) => v > 2\*\*53 ? BigInt\(v\) : v, but v is already the rounded, incorrect number. The original textual value is irrecoverably lost during parsing. The only robust solutions are: \(1\) ensuring the server sends large integers as strings, \(2\) using a streaming parser that captures numeric strings before conversion \(e.g., JSONBigint\), or \(3\) pre-processing the JSON text to quote large numbers before standard parsing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:53:51.631060+00:00— report_created — created