1. Key-Value Pairs
JSON uses key-value pairs to express an object's property. In the above example, we tried to represent a Person. This person has some properties like
Each of these properties have a value associated with it. For instance, the value of First Name is Rohatash. Age also has a value of 35. The rules for writing a Key-Value in JSON are as follows.
From the above example, a Key-Value pair is FirstName.
"FirstName" : "Rohatash"
As you can see in the figure below:
{"FirstName" : "Rohatash","Age" : 35,"Address" : "Mathura"}
2. JSON Objects Example
In JSON an object is represented by a collection of Key-Value pairs. This collection of Key-Value pairs are grouped using { } (opening and closing curly braces}. The rules for writing an Object in JSON are as follows.
Example
{
"FirstName" : "Rohatash",
"Age" : 35,
"Address" : "Mathura"
}
3. JSON Array Example
An array is a collection or list of data as defined in other language. An array in JSON is a group of values that are separated by commas. The rules for writing an Array in JSON are as follows.
Example
{
"FirstName" : "Rohatash",
"Age" : "35",
"Address" : "Mathura"
"Qualification" : ["MCA", "BTech", "BCA"]
}