JSON Data Types
A list of all JSON data types, with a description of each one.
A JSON value can be one of six data types:
- String
- Number
- Boolean
- Null
- Object
- Array
These data types are described below.
Primitives
Data Type | Description |
---|---|
String | Any sequence of Unicode code points, inserted between " and " (double quotes). Some characters may need to be escaped. See Escape Characters below for these. |
Number | Represented in base 10 with no superfluous leading zero. Can include digits between 0 and 9. It can be a negative number (e.g. |
Boolean | This can be either true or false . |
Null | Empty. |
Structures
Data Type | Description |
---|---|
Object | A JSON object is an unordered set of name/value pairs inserted between An object can contain zero or more name/value pairs. Multiple name/value pairs are separated by a |
Array | A JSON array is an ordered collection of values. It allows you to provide a list of values. A JSON array begins with |
Escape Characters
When working with strings, certain characters need to be escaped with a \
(backslash).
For example, to use a "
(double quote) within a string, you'll need to escape it. Otherwise any application reading it will think that your double quote marks the end of the string, and cut it short. This will effectively break your data import, as the application tries to interpret the rest of the string.
Here's a list outlining the characters that need to be escaped in a JSON file.
Character | Unicode Name/Code Point | Use this to escape it |
---|---|---|
" | Quotation mark (U+0022 ) | \" |
\ | Reverse solidus (U+005C ) | \\ |
/ | Solidus (U+002F ) | \/ |
Backspace (U+0008 ) | \b |
|
Form feed (U+000C ) | \f |
|
Line feed (U+000A ) | \n |
|
Carriage return (U+000D ) | \r |
|
Horizontal tab (U+0009 ) | \t |
You can also use the hexadecimal equivalent to escape a character. For example, you could use \u002f
(or \u002F
) to represent the solidus character.