2^53 + 1
- Input
- {"id": 9007199254740993}
- Expected output
- aviso na coluna 8: o JavaScript lê 9007199254740992
The output text keeps 9007199254740993.
json big number precision loss
Paste the JSON with the suspect id or decimal: every number that JavaScript cannot store exactly gets a warning with the value it would read, and the output text keeps the original digits. In the tree, the number gets a precision flag.
The output text keeps 9007199254740993.
The last digits are lost on read.
Number.MAX_SAFE_INTEGER is exact.
Precision loss in a decimal.
Overflow of the largest double.
Powers of 2 fit in a double.
The most common causes are a comma after the last item, single quotes, an unquoted key, a comment, and a missing comma between two values. JSON.parse reports only the first problem and, in some browsers, only a character position. This formatter lists every error in the text, each with line and column, shows the snippet with an arrow under the exact spot, marks the line in the editor margin, and has a Go to the error button that selects the spot.
It is 9007199254740991, or 2^53 - 1, exposed as Number.MAX_SAFE_INTEGER. Up to that value every integer has a unique representation; above it, different numbers can be read as the same one.
No. The grammar accepts any number of digits. The limit comes from implementations, and RFC 8259 recommends not expecting more precision than an IEEE 754 double offers when interoperability matters.
Send it as a string: "id": "1234567890123456789". The JavaScript receiver keeps the text, and whoever needs arithmetic converts it to BigInt. That is why several APIs offer an id_str field next to the numeric one.
No. The formatter keeps the original text of each number and writes the same digits, including trailing zeros as in 1.50. The warning exists so you know the next JavaScript program will round.