Tuesday, January 25, 2022

How many data type are supporting to JSON ?

This article is dedicate to Atos employee During the interview he asked me this question.

"How many data type are  supporting  to JSON ?"

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

  • a string
  • a number
  • an object (JSON object)
  • an array
  • a boolean
  • null

JSON values cannot be one of the following data types:

  • a function
  • a date
  • undefined

JSON String, Number

Strings in JSON must be written in double quotes.

Example:- {"name":"John", "age":12}

JSON Objects

Values in JSON can be objects.

Example:-

 {
"employee":{"name":"John""age":30"city":"New York"}
}

Objects as values in JSON must follow the JSON syntax.

JSON Arrays

Values in JSON can be arrays.

Example:-

{
"employees":["John""Anna""Peter"]
}

JSON Blooleans

Values in JSON can be true/false. 

Example:-

{"sale":true}

JSON null

Values in JSON can be null.

Example:-

{"middlename":null}

No comments:

Post a Comment