JSON (source code)

= JSON
{c}

\b[JSON], short for JavaScript Object Notation, is a textual data interchange format used for <serialization>. Its values are objects, arrays, strings, numbers, Boolean values and `null`. Object member names are strings; array elements are ordered. A complete <JSON> text may represent a single value, including a number or string.<The JavaScript Object Notation (JSON) Data Interchange Format>[RFC8259, §§1–2 and4–5]{ref}

The format's syntax and an implementation's numerical precision are separate. For an original example, consider `{"n":9007199254740993}`. A <JavaScript> call to `JSON.parse` produces a Number whose decimal value is `9007199254740992`; the requested <integer> $2^{53}+1$ has rounded to $2^{53}$ in the <double-precision floating-point format>. The same input decoded by <Python>'s default `json.loads` retains the <integer> 9007199254740993 exactly.

Encoding the digits as `{"n":"9007199254740993"}` preserves them as a <string data type>[string] in both examples, but changes the represented type. Any later numerical interpretation needs an agreed rule. RFC8259 identifies the <integer> interval $[-(2^{53})+1,(2^{53})-1]$ for exact agreement with commonly used numerical implementations; it does not restrict valid <JSON> numerals to that interval.<The JavaScript Object Notation (JSON) Data Interchange Format>[§6: number magnitude, precision and interoperability]{ref}

For exchange between systems outside a closed ecosystem, RFC8259 requires <UTF-8>.<The JavaScript Object Notation (JSON) Data Interchange Format>[§8.1: character encoding]{ref} Defining a textual format therefore addresses portable syntax, while faithful <deserialization> also requires agreement about the values an application expects.