JSON data format is derived from the Javascript language. That is why datatypes that it uses are also derived from the Javascript.
Datatypes which JSON supports:
In contrast with Javascript JSON cannot use following data types:
Below we will review each of the supported types in detail.
Boolean data type can have two values: true or false. For example:
{ “complete”: true, “commited”: false }
JSON schema located at http://json-schema.org/schema# defines two types which can define a numeric value: number and integer.
“Number” data type is a decimal (hexadecimal and octal is not supported) integer or floating-point data type. Integer defines any number with a zero fractional part.
{
“salary”: 1500,
“bonus”: 300.5
}
String data type represents a sequence of characters. String could contain zero or more characters from the Unicode character set.
{
“intro”: “hello world”
}
Array is a complex JSON data type which contains a sequence of elements which could be either of simple data type, or array, or object.
{
“directions”: [“up”, “down”, “left”, “right”]
}
Object data type is a complex JSON data type which contains a set of key/value pairs. Keys should be strings and values could be of any data type supported by JSON.
“carspec”: {
“engine”: “2.0L”,
“doors”: 4,
“automatic”: true
}
Null is used to identify missing or unknown data. Null is not actually a data type but a notation which defines a value outside of the range of values of the data type or unknown value.
{
“location”: null
}
File Extension Info | |
---|---|
JavaScript Object Notation | |
MIME TYPE | |
application/json | |
JSON File Opens With | |