Explain JSON Structure.

Solution

JSON comprises of two parts i.e key and value also known as key/value pair.

  • Key: A key is string enclosed in quotation marks.
  • Value: A value can be a string, number, boolean expression, array, or object.

Value Representation

Types of Values

  • Array
  • Boolean
  • Number
  • Object
  • String

For example:-

{
     "firstName": "Amit",
     "lastName": "Gupta",
     "address": {
         "streetAddress": "P-265",
         "city": "Gurgaon",
         "state": "Haryana",
         "postalCode": 122015
     },
     "phoneNumberList": [
         "9999999999",
         "8888888888"
     ]
 }

In above JSON data,

firstName is a key whereas "Amit" is value i.e of String type.

postalCode is key whereas 122015 is value of Number type.

phoneNumberList is key whereas ["9999999999", "8888888888"].

address is key whereas the data within it is object type.

Share this thread

Comments

Comments
comments powered by Disqus

Navigation

Social Media