JSON types
JSON types for the FairCom DB
JSON types for the FairCom DB
JSON consists of one or more JSON values that can be nested inside each other.
Section | Description |
---|---|
JavaScript Object Notation (JSON) is a simple format for representing data. | |
The JSON data type is a field type in the FairCom server. | |
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 array contains one or more JSON values. | |
A JSON object is a set of JSON properties. | |
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. | |
A JSON number value is a signed, decimal floating point number. | |
A JSON string value is a sequence of UTF-8 characters enclosed by double quotes. | |
A JSON Boolean value is | |
A JSON null value is |
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" ] ] }
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.
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.
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" } ]
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 }
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"
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.
A JSON string value is a sequence of UTF-8 characters enclosed by a set of quotation marks (""
).
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.
"property1": "value1"
A JSON Boolean value is true
or false
.
"childProperty": true
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.