JSON

From Wikipedia, the free encyclopedia

JavaScript Object Notation
JSON vector logo.svg
Filename extension
.json
Internet media type
application/json
Type codeTEXT
Uniform Type Identifier (UTI)public.json
Type of formatData interchange
Extended fromJavaScript
StandardSTD 90 (RFC 8259), ECMA-404, ISO/IEC 21778:2017
Open format?Yes
Websitejson.org

JSON (JavaScript Object Notation, pronounced /ˈsən/; also /ˈˌsɒn/) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values). It is a common data format with a diverse range of functionality in data interchange including communication of web applications with servers.

JSON is a language-independent data format. It was derived from JavaScript, but many modern programming languages include code to generate and parse JSON-format data. JSON filenames use the extension .json.

Douglas Crockford originally specified the JSON format in the early 2000s.

Naming and pronunciation[]

The acronym originated at State Software, a company co-founded by Douglas Crockford and others in March 2001.

The 2017 international standard (ECMA-404 and ISO/IEC 21778:2017) specifies "Pronounced /ˈ.sən/, as in 'Jason and The Argonauts'".[1][2] The first (2013) edition of ECMA-404 did not address the pronunciation.[3] The UNIX and Linux System Administration Handbook states that "Douglas Crockford, who named and promoted the JSON format, says it's pronounced like the name Jason. But somehow, 'JAY-sawn' seems to have become more common in the technical community."[4] Crockford said in 2011, "There's a lot of argument about how you pronounce that, but I strictly don't care."[5]

Standards[]

After RFC 4627 had been available as its "informational" specification since 2006, JSON was first standardized in 2013, as ECMA-404.[6] RFC 8259, published in 2017, is the current version of the Internet Standard STD 90, and it remains consistent with ECMA-404.[7] That same year, JSON was also standardized as ISO/IEC 21778:2017.[1] The ECMA and ISO standards describe only the allowed syntax, whereas the RFC covers some security and interoperability considerations.[8]

History[]

Douglas Crockford at the Yahoo Building (2007)

JSON grew out of a need for stateless, real-time server-to-browser communication protocol without using browser plugins such as Flash or Java applets, the dominant methods used in the early 2000s.[9]

A precursor to the JSON libraries was used in a children's digital asset trading game project named Cartoon Orbit at Communities.com (at which State Software's co-founders had all worked previously) for Cartoon Network, which used a browser side plug-in with a proprietary messaging format to manipulate Dynamic HTML elements (this system is also owned by 3DO). Upon discovery of early Ajax capabilities, digiGroups, Noosh, and others used frames to pass information into the user browsers' visual field without refreshing a Web application's visual context, realizing real-time rich Web applications using only the standard HTTP, HTML and JavaScript capabilities of Netscape 4.0.5+ and IE 5+.[citation needed]

Crockford first specified and popularized the JSON format.[10] The State Software co-founders agreed to build a system that used standard browser capabilities and provided an abstraction layer for Web developers to create stateful Web applications that had a persistent duplex connection to a Web server by holding two Hypertext Transfer Protocol (HTTP) connections open and recycling them before standard browser time-outs if no further data were exchanged. The co-founders had a round-table discussion and voted whether to call the data format JSML (JavaScript Markup Language) or JSON (JavaScript Object Notation), as well as under what license type to make it available. Chip Morningstar developed the idea for the State Application Framework at State Software.[11][12]

The system was sold to Sun Microsystems, Amazon.com and EDS. The JSON.org[13] website was launched in 2002. In December 2005, Yahoo! began offering some of its Web services in JSON.[14]

JSON was based on a subset of the JavaScript scripting language (specifically, Standard ECMA-262 3rd Edition—December 1999[15]) and is commonly used with JavaScript, but it is a language-independent data format. Code for parsing and generating JSON data is readily available in many programming languages. JSON's website lists JSON libraries by language.

In October 2013, Ecma International published the first edition of its JSON standard ECMA-404.[6] That same year, RFC 7158 used ECMA-404 as a reference. In 2014, RFC 7159 became the main reference for JSON's Internet uses, superseding RFC 4627 and RFC 7158 (but preserving ECMA-262 and ECMA-404 as main references). In November 2017, ISO/IEC JTC 1/SC 22 published ISO/IEC 21778:2017[1] as an international standard. On 13 December 2017, the Internet Engineering Task Force obsoleted RFC 7159 when it published RFC 8259, which is the current version of the Internet Standard STD 90.[16][17]

Crockford added a clause to the JSON license stating that "The Software shall be used for Good, not Evil," in order to open-source the JSON libraries while mocking corporate lawyers and those who are overly pedantic. On the other hand, this clause led to license compatibility problems of the JSON license with other open-source licenses, as open-source software and free software usually imply no restrictions on the purpose of use.[18]

Syntax[]

The following example shows a possible JSON 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
}

Character encoding[]

Although Crockford originally asserted and believed that JSON is a strict subset of JavaScript and ECMAScript,[19] his specification actually allows valid JSON documents that are not valid JavaScript; JSON allows the Unicode line terminators U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR to appear unescaped in quoted strings, while ECMAScript 2018 and older does not.[20][21] This is a consequence of JSON disallowing only "control characters". For maximum portability, these characters should be backslash-escaped.

JSON exchange in an open ecosystem must be encoded in UTF-8.[7] The encoding supports the full Unicode character set, including those characters outside the Basic Multilingual Plane (U+10000 to U+10FFFF). However, if escaped, those characters must be written using UTF-16 surrogate pairs. For example, to include the Emoji character U+1F610