JSON Data Types

Valid data types

In JSON, values must be one of the following data types:

  • String
  • Number
  • Object (JSON Object)
  • Array
  • Boolean
  • Null

JSON ValuesCannotIs one of the following data types:

  • Function
  • Date
  • undefined

JSON String

Strings in JSON must be enclosed in double quotes.

Example

{"name":"Bill"}

JSON Number

Numbers in JSON must be integers or floating-point numbers.

Example

{"age":30}

JSON Object

Values in JSON can be an object.

Example

{
"employee":{ "name":"Bill Gates", "age":62, "city":"Seattle" }
}

Objects used as values in JSON must follow the same rules as JSON objects.

JSON Array

Values in JSON can be an array.

Example

{
"employees":[ "Bill", "Steve", "David" ]
}

JSON Boolean

Values in JSON can be true/false.

Example

{"sale":true}

JSON null

Values in JSON can be null.

Example

{"middlename":null}