Can a reader keep every digit of a number?
04Compare written digits with a common reader’s stored result, then try sending an identifier as text.
We want the receiving app to keep the intended value. A very large identifier may need every written digit.
Written digits
9007199254740993
A finite storage format has room for only some possible numbers.
What happens if you change this?
Make one change, then watch again. Restart restores the original example.
A valid token can still exceed the receiver’s range or lose expected precision.
Key idea: A number can be spelled correctly and still be too large or precise for a reader. Agree on the value type and capacity.
Terms
- JSON
- JavaScript Object Notation: shared rules for writing data as text. Apps in many languages use it.
- Object
- A group of named values, like drawers with different labels.
- Array
- A list whose values have meaningful positions.
- String
- A text value between quotation marks.
- Grammar
- Rules for which marks and words may appear and where.
- Interoperability
- Different apps can read the same data and agree about its meaning.
- Binary64
- A common number storage format with finite space. Near very large numbers it cannot represent every neighboring integer.
- Precision
- How much detail a stored number can keep without rounding it away.
Rules & examples
Correct spelling and the reader’s numeric capacity are separate checks.
- Extra leading zeroes in the integer component, NaN, and Infinity are not valid JSON number forms. A leading plus is not allowed. Fractional zeros and exponent zeros are allowed (verified erratum 7600).
- Parsers may limit accepted magnitude and precision; a syntactically valid token such as 1E400 can exceed common capabilities.
- With IEEE 754 binary64 implementations, integers from −(2^53)+1 through (2^53)−1 are interoperable with exact agreement.
The RFC describes broad interoperability, not a promise that every runtime accepts the same arbitrary-precision numbers. Applications needing large identifiers often define a string representation in their own schema.
RFC 8259 §6: number = optional minus, integer, optional fraction and exponent. Extra leading zeros in the integer component are forbidden; 0.001 and 1E01 are valid (verified erratum 7600). NaN and Infinity tokens are forbidden; 1E400 is grammatical but problematic. In binary64, integers in [−(2^53)+1, (2^53)−1] have exact interoperable agreement. Not every integer beyond this interval is inexact. This example uses JavaScript binary64; strings need an application convention.
Sources
New to this? Start hereA quick picture + helpful background
First, agree how to read the message.
An encoding tells a reader how to interpret bytes. A format tells it how values fit together. Correctly reading a value does not make that value trustworthy.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.