What is JSON?

JSON (Java Script Object Notation) used as data transfer format. Because JSON is lightweight, easy to understand, manipulate and generate, it has almost replaced XML which was used previously as the only data-interchange format. It is because of the reasons that:

  • XML is heavier than JSON
  • to parse XML, we have to use xPath which is an overhead removed in JSON because JSON is native to JavaScript
  • XML uses tags to describe user data and tags increase the size of data

Data in JSON is represented in the form of Objects and Arrays:

JSON Object:

A JSON Object is an unordered set of name/value pairs separated by a comma ( , ). Each object begins with a left brace ( { ) and ends with a right brace ( } ) and each value pair in an object is separated by a colon ( : ).

JSON Array:

A JSON Array is an ordered collection of values which may contains many comma ( , ) separated JSON Objects. It begins with left bracket ( [ ) and ends with right bracket ( ] ) and JSON Objects in it are separated by comma ( , ).

{ “students” : [

{“id”:1, “name”:”Adnan Sohail”},

{“id”:2, “name”:”Irfan Razzaq”}

]

}

Leave a comment