JSON consists of one or more JSON values that can be nested inside each other.
| Section | Description |
|---|---|
| JSON | JavaScript Object Notation (JSON) is a simple format for representing data. |
| JSON data type | The JSON data type is a field type in the FairCom server. |
| JSON value | A JSON value is the building block of JSON . A JSON value can stand alone or can be nested inside another JSON value. |
| JSON array | A JSON array contains one or more JSON values. |
| JSON object | A JSON object is a set of JSON properties. |
| JSON property | A JSON property has a name and a value where the name may be any string value and the value may be set to any JSON type. |
| JSON number | A JSON number value is a signed, decimal floating point number. |
| JSON string | A JSON string value is a sequence of UTF-8 characters enclosed by double quotes. |
| JSON Boolean | A JSON Boolean value is true or false. |
| JSON null | A JSON null value is null. |
JSON
JavaScript Object Notation (JSON) is a simple format for representing data. It requires very little markup and is flexible enough to represent the majority of data structures. It is self-describing, which makes it ideal for schemaless applications and searches. It can optionally be paired with a schema to define an expected structure.
Each JSON document contains one JSON value. A value can be one of a variety of JSON types. Some JSON types, such as JSON object and JSON array, allow JSON values to be nested to create complex structures.
{
"stringProperty": "value1",
"numberProperty": -123.456,
"booleanProperty": false,
"nullProperty": null,
"objectProperty":
{
"childProperty": true
},
"arrayProperty":
[
"1",
2,
3.4,
true,
null,
{ "child":"object" },
[ "child", "array" ]
]
}
JSON data type
The JSON data type is a field type in the FairCom server. Its length can be up to 2 billion bytes or be limited to a length between 1 and 65,500 bytes. The JSON data type is flexible because it may contain any number and a variety of properties and values, including objects, arrays, strings, numbers, true, false, and null. See Data types.
A table may contain a mix of JSON fields for flexibility and strongly typed fields for predictability. For maximum flexibility, a table may have as few as two fields; an "id" field to uniquely identify each record and a JSON field to store any possible value in each record.
JSON value
A JSON value is the building block of JSON . A JSON value can stand alone or can be nested inside another JSON value.
A JSON value is strongly typed as one of the JSON types: JSON object, JSON array, JSON string, JSON number, JSON Boolean, or JSON null.
JSON array
A JSON array contains one or more JSON values. Each JSON value may be any JSON type. An array starts with the left square bracket ([) character, contains zero or more values separated by the comma (, ) character, and ends with the right square bracket (]) character — for example, [ 1, 2, 3] or [ "a", "b", "c"].
Each value in a JSON array can be any type, but it is best practice for each value in a JSON array to have the same type, such as an array of strings, numbers, or objects where each object has the same structure.
A consistent structure allows an array to be indexed for reliable query results.
[
{
"name": "mike",
"eats": "pizza"
},
{
"name": "teresa",
"eats": "chocolate"
}
]JSON object
A JSON object is a set of JSON properties. Each JSON property in an object must have a unique name. An object starts with the left curly bracket ({) character, contains zero or more properties separated by the comma (, ) character, and ends with the right curly bracket (}) character.
{
"property1": "value1",
"property2": false
} JSON property
A JSON property has a name and a value where the name may be any string value and the value may be set to any JSON type.
The name part of a property begins with the quotation marks (") followed by one or more UTF-8 characters and ends with the quotation marks (").
The name is followed by the colon (:) character to separate it from the value.
The value may be any JSON type. Each type has its own formatting rules: JSON object, JSON array, JSON string, JSON number, JSON Boolean, or JSON null.
White space can be inserted between the parts of a JSON property and between the property and the JSON object that contains it.
A JSON property by itself is not a valid JSON document; it must be part of a JSON object.
"myProperty":"myValue"
JSON number
A JSON number value is a signed, decimal floating point number. It is represented as a sequence of ASCII numeric digits with an optional plus (+) or minus (-) character at the beginning and an optional decimal point in the middle — for example, -91.2247.
A JSON number is not a binary floating point number and does not have problems with rounding and precision, but some JSON parsers incorrectly convert it into a binary floating point number and create these problems. Thus, it is safest to represent numbers in JSON within a JSON string.
JSON string
A JSON string value is a sequence of UTF-8 characters enclosed by a set of quotation marks ("").
Example string:
"my string"
There is no official limit to the number of characters in a string, but the practical limit is typically around 1 megabyte. The FairCom server supports JSON strings up to 2 GB in length.
JSON requires the characters in the following table to be escaped
| Character requiring escaping | JSON escape sequence | Example JSON string |
|---|---|---|
| \ | \\ | "Embedded backslash \\ in a string" |
| " | \" | "Embedded double quote \" in a string" |
| Backspace (U+0008) | \b | "Embedded backspace \b in a string" |
| Formfeed (U+000C) | \f | "Embedded formfeed \f in a string" |
| Linefeed (U+000A) | \n | "Embedded linefeed \n in a string" |
| Carriage return (U+000D) | \r | "Embedded return \r in a string" |
| Horizontal tab (U+0009) | \t | "Embedded tab \t in a string" |
| Remaining control characters from U+0000 to U+001F | \uDDDD | "Embedded null char \0000 in a string" |
JSON Boolean
A JSON Boolean value is true or false.
"childProperty": true
JSON null
A JSON null value is null. The convention in JSON is that omitting a property and setting it to null are the same thing. In contrast, setting a property to an empty value ("", {}, [], or [{}] ) are not the same thing as null. An application using JSON must determine the meaning of these empty values.