Introduction to the JSON formalism
JSON is an open, text-based data exchange format (see RFC 4627). Like XML, it is human-readable, and platform independent. Data formatted according to the JSON standard is lightweight and can be parsed by JavaScript implementations with incredible ease, making it an ideal data exchange format for web applications.
The information transported through JSON is always in form of the following basic types:
- strings: double-quoted Unicode (UTF-8 by default), with backslash escaping
- numbers
- Boolean values: true or false
- null
The JSON building block is the name-content tuple. The name is always a quote-enclosed string and is separated from the content by a “:” character. The content of a JSON tuple can be either:
- A value in one of the basic types
Example : “firstName” : “Ted” - An ordered set of contents, delimited by square brackets (“[” “]”)
Example: “continents” : [ “Europe” , “Africa”, “Asia”, “Americas”, “Australia”, “Antarctica” ] - A JSON object. JSON objects are unordered sets of name-content pairs. The only restriction is
that within a set the names are unique. The name-content pairs are separated by a comma (“,”)
and enclosed by curly brackets (“{“ “}”)
Example: { “street” : “Augartenstrasse”, “number” : 1, “city” : “Karlsruhe”, “country” : “Germany”}
This is it! JSON is simple, yet very expressive and also less verbose than XML.