There have been many descriptions of the JSON format. ECMA-404 includes some of this history, quoted here with links added:
JSON was first presented to the world at the JSON.org website in 2001. A definition of the JSON syntax was subsequently published as IETF RFC 4627 in July 2006. ECMA-262, Fifth Edition (2009) included a normative specification of the JSON grammar. This specification, ECMA-404, replaces those earlier definitions of the JSON syntax. Concurrently, the IETF published RFC 7158/7159 and in 2017 RFC 8259 as updates to RFC 4627. The JSON syntax specified by this specification and by RFC 8259 are intended to be identical.
It must be noted that Tim Bray, editor of RFC 8259, actually recommends using I-JSON (RFC 7493) and none of the above mentioned specifications. Because it “explicitly rules out some legal-but-dumbass things”. (2017-12-14 : The Last JSON Spec (archived).)
HTML first gives you automatic JSON
You should always support a human readable HTML page of any data you publish, and mark it up with microformats2. At that point you don't need a separate JSON representation, because microformats2 parsers give you back canonical JSON which you can then serve if you wish, e.g. see Aaron Parecki's example below.
Accepting JSON POST requests
JSON does not have as wide support for POST requests compared to form-encoded requests.
In most web frameworks you have to jump through hoops to read the raw POST data if it's JSON format.
A Google search can confirm that lots of people are confused about how to handle JSON POST requests: how to receive JSON post in php, ruby, python, node
"I ditched content negotiation because it turned out to be a huge maintentance chore of very little actual value. ...the .json view was essentially the same as the parsed microformat view, and I never used it so it kept breaking"
Previously, Aaron Parecki returned JSON representations of URLs by appending ".json". However, in 2016-01 when Aaron launched the new version of his website, the new site did not support this feature.
"My .json view is *literally* the parsed microformat view. As in, I render the HTML as normal, then pass it through mf2-php before responding. It's like getting content negotiation for free."
Also see: p3k
- JSON Formatter
- JSONView - Chrome plugin which pretty-prints JSON
- JSON Formatter - A Safari extension which makes valid JSON documents human-readable.
- JSON Generator - define a schema and generate sample JSON data for testing
- RFC7493 The I-JSON Message Format: Internet JSON for interoperability between JSON parsers
- "It is a truth universally acknowledged, that a working group in possession of a problem, must be in want of a new JSON format." @dauwhe November 7, 2017
- JSONx an “IBM® standard format to represent JSON as XML.”
- JSON Canonicalization Scheme (JCS) (RFC 8785) for a canonical JSON format, which of course also links to more specs trying to do the same thing (Appendix H).
- Microsoft has a format they call JSON with Comments and refer to as jsonc. This is used in tools like VSCode and and has an open-source parser. But should not be confused with jsonc another alternative JSON format, JSONC the JSON compressor, or json-c the C JSON implementation.
- The original license includes the line "The Software shall be used for Good, not Evil." This has lead to discussions about it not being OSS.
- XSL Transformations (XSLT) Version 3.0 (W3C Recommendation) specifies JSON to XML transformation, giving another way to express JSON as XML.
- From UBJSON, a binary format for JSON: “Attempts to make using JSON faster through binary specifications like BSON, BJSON or Smile exist”. Another wide split in different specifications having come from original JSON.
- JSONH, a “way to pack and unpack generic homogenous collections” (e.i. lists of objects to just flat arrays). For when you want to store JSON objects in JSON but in less bytes.
- PipeWire and its policy manager WirePlumber implement a dialect called SPA JSON:
- 2022-10-27 : From Lua to JSON: refactoring WirePlumber's configuration system (archived) gives some examples of what would have the same parser outcomes.
- PipeWire calls it “Relaxed JSON variant parsing.” The SPA stands for Simple Plugin API and has nothing to do with the JSON itself.
- It looks like the implementations for WirePlumber (docs, merge request) came later and is different from the one for PipeWire (docs, original commit). Neither docs will actually tell you what is relaxed, thus why the first mentioned blogpost by Ashok is valuable. One way to find out how the parser works is to read all the commit messages, like commit 49b17bca explaining what relaxing was done to the parser (archived).
- JSON5 dubs itself “JSON for Humans” and has the goal to be used for JSON that is written by hand rather than as a data communication format between computers.
- It has a formal spec that describes it as a superset of RFC 7159 and a subset of ECMA-262, 5.1 Edition.
- newline-delimited JSON http://ndjson.org/