JSON RFC 8259 Specification
The JSON data interchange format grammar, value types, and interchange rules per RFC 8259.
Value Types
JSON defines six structural value types organized into a tree rooted at a single value. The scalar types are string, number, boolean, and null, while the composite types are object and array. Strings are double-quoted Unicode with escape sequences, numbers are decimal with optional exponent, and booleans are the literals true and false. The format is intentionally minimal to maximize interoperability across languages.
- object
- Unordered collection of name-value pairs
- array
- Ordered sequence of values
- string
- Double-quoted Unicode with escapes
- number
- Decimal with optional fraction and exponent
- true/false/null
- Boolean and null literals
{"a": 1} [1, 2, 3] "hello" 1.5e3 true, null Interchange Encoding
RFC 8259 requires that JSON exchanged between systems be encoded in UTF-8, removing the earlier ambiguity that allowed UTF-16 and UTF-32. A JSON text must be a single scalar, object, or array value, though some parsers accept bare scalars leniently. Duplicate member names within an object are not forbidden but produce implementation-defined behavior, so generators should avoid them. Numbers with leading zeros or plus signs are invalid.
Number Precision Pitfalls
JSON numbers have no explicit integer or float distinction, leading to precision loss when parsed into language-native doubles. Integers exceeding 2 to the 53 cannot be represented exactly in a JavaScript number. Protocols requiring integer precision should encode large integers as strings or use a JSON Schema format annotation. Always validate number ranges in application logic rather than relying on parser behavior.