Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JSON Data Types

Valid Data Types

In JSON, values can be one of the following types:

  • A string
  • A number
  • An object (JSON object)
  • An array
  • A boolean
  • Null

JSON values cannot be of the following types:

  • Functions
  • Dates
  • Undefined

JSON Strings

In JSON, strings must be enclosed in double quotes.

Example

{“name”:“John”}

JSON Numbers

In JSON, numbers must be either integers or floating-point values.

Example

{“age”:30}

JSON Objects

In JSON, values can include objects.

Example

{
“employee”:{“name”:“John”“age”:30“city”:“New York”}
}
In JSON, objects used as values must adhere to JSON syntax rules.

JSON Arrays

In JSON, values can consist of arrays.

Example

{
“employees”:[“John”“Anna”“Peter”]
}

JSON Booleans

In JSON, values can be either true or false.

Example

{“sale”:true}

JSON null

In JSON, values can also be null.

Example

{“middlename”:null}