SYNTAX
JSON syntax allows the representation of three types of values:
- Simple values—Strings, numbers, Booleans, and
null
can all be represented in JSON using the same syntax as JavaScript. The special valueundefined
is not supported. - Objects—The first complex data type, objects represent ordered key-value pairs. Each value may be a primitive type or a complex type.
- Arrays—The second complex data type, arrays represent an ordered list of values that are accessible via a numeric index. The values may be of any type, including simple values, objects, and even other arrays.
There are no variables, functions, or object instances in JSON. JSON is all about representing structured data, and although it shares syntax with JavaScript, it should not be confused with JavaScript paradigms.
Simple Values
In its simplest form, JSON represents a small number of simple values. For example, the following is valid JSON:
5
This is JSON that represents the number 5. Likewise, the...