This section contains a brief description of how JSON data is structured. JSON data is typically stored in a JSON (instance) document but can also be stored as a JSON data fragment in a document of another type. A JSON data fragment or document is a JSON data structure, which is broadly defined as set out below.
XMLSpy additionally supports JSON5, which is an extension of JSON that adds some minimal ECMScript 5 extensions. See json5.org for more information.
JSON objects and arrays
A JSON document (saved typically with the file extension .json) is built on the following core data structures:
An object is delimited by curly braces, and is an unordered collection of zero or more key:value pairs. These key:value pairs are the properties of the object. The key must always be a string and must therefore always be enclosed in quotes. The key (also called the name of the property) is separated from its value by a colon. A property value can be of any JSON datatype (see list below). A property is separated from the next by a comma. The listing below is an example of an object with three properties (all of which have atomic-type values):
An array is delimited by square brackets, and is a comma-separated ordered list of zero or more items. These items can be of any JSON datatype (see list below).
The array below consists of two objects (each enclosed in curly braces). The array itself is indicated with square brackets.
The listing below is of an object with three key:value pairs. Each value is an array that contains a tuple (sequence). (A tuple can be considered to be a one-dimensional array.) The three items in each tuple are atomic types.
"x": [ 1, 2, "abc" ],
"y": [ 3, 4, "def" ],
"z": [ 5, 6, "ghi" ]
Object property values and array items can be of the following types:
•string (must be enclosed in quotes). A string can additionally be specified to have a format, such as a date-time or email format
•number: A number with a fractional part; it includes integers
•integer: A number with no fractional part; a subset of the number type
•boolean (true/false, not enclosed in quotes)
•object: When used within another object, allows data to be nested
•array: Provides the ability to build more complex structures than allowed by objects
•null (null, not enclosed in quotes)
Example of JSON data
Here is an example of a JSON data fragment. Note how the document is structured into objects and arrays. Also note the data type of key values; string values are in quotes, other types are colored green.
"street": "Jason Avenue",
"postcode": "JS12 ON34"
"number": "12 3456-7890"
"number": "789 012-34567"
•JSON5 supports comments. Comments are delimited like this: // comment // or /* comment */.
•In JSON5, the keys of key:value pairs do not need to be enclosed in quotes.
•In JSON5, strings can be written across multiple lines.
•JSON5 documents can be validated against JSON schemas.