Open JSON File

Information, tips and instructions

JSON Data Types

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:

  • Boolean
  • Integer
  • Number
  • String
  • Object
  • Array
  • Null

In contrast with Javascript JSON cannot use following data types:

  • Function
  • Date
  • Undefined

Below we will review each of the supported types in detail.

Boolean

Boolean data type can have two values: true or false. For example:

{ “complete”: true, “commited”: false }

Number and Integer

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

String data type represents a sequence of characters. String could contain zero or more characters from the Unicode character set.

{
“intro”: “hello world”
}

Array

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

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

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
}