What are the data types supported by JSON?

Answered

What are the data types supported by JSON?

Ninja Asked on 18th September 2018 in JSON.
Add Comment
1 Answer(s)
Best answer

JSON defines two data structures:

  1. Collection of name-value pairs (objects)
  2. Ordered list of values (array)

JSON defines the following data types for the values:

  • Object – An object is an unordered set of name/value pairs. An object begins with ‘{‘ and ends with ‘}’. Each name is followed by ‘:’ (colon) and the name/value pairs are separated by ‘,’ (comma).
  • Array – An array is an ordered collection of values. An array begins with ‘[‘ and ends with ‘]’. Array values are separated by ‘,’ (comma).
  • String – A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes.
  • Number –  A number is a signed decimal number that may contain a fractional part and may use exponential E-notation. JSON does not allow non-numbers like NaN, nor does it make any distinction between integer and floating-point.
  • Boolean – A boolean is either of the values true or false.
  • null – An empty value, using the word null.
Ninja Answered on 18th September 2018.
Add Comment