JSON→URL
JSON→URL logo
Type codeTEXT
Type of formatData interchange
Extended fromJSON
Open format?Yes
Websitejsonurl.org

JSON→URL is a language-independent data interchange format for the JSON data model[1] suitable for use within a URL/URI query string. It is defined by an open specification,[2] though not through a standards body.

Data types and syntax

JSON→URL implements the JSON data model:,[1] with support for the following data types[2]

  • 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 true or false
  • null: an empty value, using the word null
  • 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 + or %20.
  • 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,[3] 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

Example

The following example shows a possible JSON→URL representation describing a person.

(firstName:John,lastName:Smith,isAlive:true,age:27,address:(streetAddress:21+2nd+Street,city:New+York,state:NY,postalCode:10021-3100),phoneNumbers:((type:home,number:212+555-1234),(type:office,number:646+555-4567)),children:(),spouse:null)

Differences from JSON

JSON→URL implements the JSON data model,[1] however, it does not differentiate between an empty object and an empty array. Instead, it defines an empty composite value as ().

Data portability

JSON→URL exchange in an open ecosystem must be encoded in UTF-8.[2] 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 42, 42.0, and 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.

Semantics

While JSON→URL provides a syntactic framework for data interchange, unambiguous data interchange also requires agreement between producer and consumer on the semantics of a specific use of the JSON→URL syntax. One example of where such an agreement is necessary is the serialization of data types local to a specific implementation (e.g. Java, JavaScript) that are not defined in the JSON→URL specification, such as Date.

References

  1. 1 2 3 Bray, Tim (December 2017). "The JavaScript Object Notation (JSON) Data Interchange Format". IETF. Retrieved 16 February 2018.
  2. 1 2 3 "JSON→URL Specification". Ongoing. Retrieved 20 July 2020.
  3. "The JSON Data Interchange Format" (PDF). ECMA International. October 2013. Retrieved 24 October 2019.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.