JavaScript Object Notation (JSON)

JSON rapidly became very popular in the realm of Web development. It uses a mixture of array, which are ordered sequences of JSON items; objects, which are unordered collections of key-value pairs in which the key is a string and the value is any JSON item,;and, finally, values such as integers and strings. This is sufficient to represent static JavaScript objects (there are no function items).

JSON has taken over from XML for the purpose of exchanging program-generated data via distributed APIs (largely replacing the use of SOAP) and for configuration of Web-based software. The notation uses square brackets for arrays and curly braces for objects, making it familiar to programmers of C-like languages and also allowing automatic brace-matching in many widely-used text editors.

Large JSON files can be difficult to edit directly, as you can end up with large numbers of closing braces in a clump, reminiscent of LISP. It’s slightly easier than HTML in this regard, though, where you can end up with masses of </div> tags together, given that text editors tend not to support tag-matching (show me the start tag corresponding to this close tag) but do support brace-matching.

JSON does not support mixed content: that is, you can’t have running text with embedded markup. You can represent mixed content with an array of mixed strings and objects, but is not suitable for manipulation without tools or programs, and is considerably more verbose than the corresponding Markdown or even XML or HTML markup in this case. It’s also easy to lose significant spaces around the embedded markup when working in this fashion.

There are libraries to import JSON files, and often to export them, in all major programming languages today. Often, reading JSON results in language-native objects, so that no query language is needed in simple cases. This is a marked contrast from XML or HTML, where the result is usually a relatively complex data structure.

JSON, then, is strongly favoured by many developers over any of the other formats in this paper because it is much easier for them. JSON belongs in a context in which the format of the data, the exact representation of information, and even the choice of what is to be represented is in the hands of programmers. In contexts in which document authors own their data and choose the contents, or where interoperability of the information between applications is paramount, JSON is much weaker than XML or RDF. However, see the next section for JSON and RDF.