Aina za data za JSON

Valid data types

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

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

JSON valuesCannot beIs 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}

Mwongozo wa JSON

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.

Makampuni ya JSON

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}