What is JSON?

02 April 2022 | Viewed 1100 times

JSON stands for JavaScript Object Notation, a lightweight format for storing and transporting data.
JSON is "self-describing" and easy to understand

JSON examples


JSON Data represents a Name and a Value pair.

Json
{ "firstName" : "Venkat" }


JSON can contain multiple name/value pairs and each pair should be separated by a comma.

Json
{
"firstName" : "Venkat",
"last Name" : "Cherukuru",
"age" : 35,
country : "India"
}


Attribute Name should be single word. If Attribute Name has multiple words, then it should quoted to make single word.
JSON can contain arrays of strings, number or objects (object can be again an JSON). JSON Array should be written inside square brackets.

One dimensional arrays can be simply defines with comma (,) separated inside square brackets.

To add multi dimensional array, each item in array should be defined as a induvial JSON with all attributes contains in the item.

Json
// array of strings
{
countries : [ "India", "USA", "Canada" ]
}

// array of integers
{
zipCodes : [ 22042, 22043, 20170, 20172 ]
}

// array of objects
{
cities : [
{ "code" : "VA", "name" : "Virginia" },
{ "code" : "CA", "name" : "California" },
{ "code" : "NY", "name" : "New York" }
]
}