JSON JSON Syntax Rules


Example

JSON (JavaScript Object Notation) syntax is based on a subset of JavaScript (see also json.org).

A valid JSON expression can be one of the following data types

  • simple data types: String, Number, Boolean, Null
  • composite data types: Value, Object, Array

Simple data types

A JSON string has to be enclosed in double quotes and may contain zero or more Unicode characters; backslash escapes are allowed. Accepted JSON numbers are in E notation. Boolean is one of true, false. Null is the reserved keyword null.

Data typeExamples of valid JSON
### String"apple"
"苹果"
"\u00c4pfel\n"
""
### Number3
1.4
-1.5e3
### Booleantrue
false
### Nullnull

Composite data types

Value

A JSON Value can be one of: String, Number, Boolean, Null, Object, Array.

Object

A JSON Object is an comma-separated unordered collection of name:value pairs enclosed in curly brackets where name is a String and value a JSON value.

Array

A JSON Array is an ordered collection of JSON values.

Example of a JSON array:

["home", "wooden"]

Examples of JSON objects:

{
    "id": 1,
    "name": "A wooden door",
    "price": 12.50,
    "tags": ["home", "wooden"]
}

[
  1,
  2,
  [3, 4, 5, 6],
  {
    "id": 1,
    "name": "A wooden door",
    "price": 12.50,
    "tags": ["home", "wooden"]
  }
]

Online tools for validating and formatting JSON data: