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
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 type | Examples of valid JSON |
---|---|
### String | "apple" |
"苹果" | |
"\u00c4pfel\n" | |
"" | |
### Number | 3 |
1.4 | |
-1.5e3 | |
### Boolean | true |
false | |
### Null | null |
A JSON Value can be one of: String, Number, Boolean, Null, Object, Array.
ObjectA 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.
ArrayA 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"]
}
]