JSON Concepts
External
Internal
JSON Document Structure
Path
Element
Data Types
JSON data types are: null, Booleans, Strings, Numbers, Objects (which can be thought of as Maps) and Arrays.
null
null is represented as a lowercase literal:
null
Booleans
Booleans are represented as lowercase literals:
true false
and they are not quoted.
Strings
Strings are represented as:
"this is a string"
and they must be quoted. This constraint helps with semantics: if we see a number in a JSON context, we know it's a number, unless is quoted, in which case we know it's a string.
Always use double quotes ("), never use single quotes ('). Single quotes are only accepted if the parser was configured so, which is not the default. See "Single Quotes vs. Double Quotes" below.
Numbers
Numbers are represented as:
10
and they are not quoted.
Objects
Objects are enclosed in curly brackets "{}" and contain fields.
The field name and the value are separated by colon (":"). The pairs are delimited by commas (",").
The field name is always a string, so it must be quoted.
{ "id" : 42, "name" : "John Doe", "married" : true "kids" : [ "Alice", "Bob" ] }
Fields
A field is a key-value pair, where the key, or the field name, is always a string.
The JSON RFC refers to the key as "names". Jackson refers to them as "field names".
The field name, is separated by the value by a semicolon (:). The value can have any of the JSON data types.
Fields can only exist inside of a JSON Object.
Arrays
Array elements are enclosed in brackets "[", and they are separated by commas:
[ "one element", "another element" ]
Comments
JSON does not support comments: https://plus.google.com/+DouglasCrockfordEsq/posts/RK8qyGVaGSr
A comment can be simulated as follows:
{ "comment":"this is a comment", ... }
Single Quotes vs. Double Quotes
Never use single quotes ('), always use double quotes ("). Single quotes are only accepted if the parser was configured so, which is not the default.
JSON Schema
Collection+JSON
Collection+JSON is a JSON-based read/write hypermedia-type designed to support management and querying of simple collections. More details http://amundsen.com/media-types/collection/.