|Type of format||Data interchange|
JSON→URL is a language-independent data interchange format for the JSON data model suitable for use within a URL/URI query string. It is defined by an open specification, though not through a standards body.
Data types and syntax
- Number: a signed decimal number that may contain a fractional part and may use exponential E notation, but cannot include non-numbers such as NaN. The format makes no distinction between integer and floating-point.
- Boolean: either of the values
- null: an empty value, using the word
- String: a sequence of zero or more Unicode characters. Strings may be delimited with single-quotation marks if the unquoted value would otherwise be interpreted as a boolean, null, or number. Otherwise, they need not be quoted. Characters which are not valid in a URL must be percent encoded. Space is encoded as
- Array: an ordered list of one or more values, each of which may be of any type. Arrays use parentheses notation with comma-separated elements.
- Object: a collection of one or more name–value pairs where the names (also called keys) are strings. Objects are intended to represent associative arrays, where each key is unique within an object. Objects are delimited with parentheses and use commas to separate each pair, while within each pair the colon character separates the key or name from its value.
- Empty: the empty composite value
The following example shows a possible JSON→URL representation describing a person.
Differences from JSON
JSON→URL exchange in an open ecosystem must be encoded in UTF-8. The encoding supports the full Unicode character set, including those characters outside the Basic Multilingual Plane (U+10000 to U+10FFFF). Unlike JSON, JSON→URL does not define a separate syntax for escaping characters within a string literal. Such characters are simply composed of one or more percent encoded octets.
Numbers in JSON→URL are agnostic with regard to their representation within programming languages. While this allows for numbers of arbitrary precision to be serialized, it may lead to portability issues. For example, since no differentiation is made between integer and floating-point values, some implementations may treat
4.2E+1 as the same number, while others may not. The JSON→URL standard makes no requirements regarding implementation details such as overflow, underflow, loss of precision, rounding, or signed zeros.
- "JSON→URL Specification". Ongoing. Retrieved 20 July 2020.
- "The JSON Data Interchange Format" (PDF). ECMA International. October 2013. Retrieved 24 October 2019.