JSON Data Types


In JSON, values must be one of the following data types: (i) a string, (ii) a number, (iii) an object (JSON object), (iv) an array, (v) a boolean, and (vi) null.

JSON strings: Strings in JSON must be written in double quotes.
{ "name": "John" }

JSON numbers: Numbers in JSON must be an integer or a floating point.
{ "age": 30 }

JSON objects: Values in JSON can be objects.
{ "employee": { "name":"John", "age":30, "city":"New York" } }

JSON arrays: Values in JSON can be arrays.
{ "employees": ["John", "Anna", "Peter"] }

JSON Booleans: Values in JSON can be true or false.
{ "sale": true }

JSON null: Values in JSON can be null.
{ "middlename": null }



Demonstration
The following demonstration shows how the script of HTML and JavaScript is displayed on the Web.

     





      I thought I’d begin by reading a poem by Shakespeare,    
      but then I thought, why should I?    
      He never reads any of mine.    
      ― Spike Milligan