As previously discussed, JSON object is utilized to hold keys and values, the following is an example of the JSON object.
[html]
{
"SPlessons":
{
"name": "Enni",
"ID": 513,
"Tutorial": "JAVA",
"Registered": true
}
}
[/html]
Keys
and
values
are separated with colon and keys are strings and values are the types of JSON, each information will be separated by comma. The
"{"
indicates the JSON object. Following is the image to understand objects in the code.
Following is the syntax to write the
JSON objects
.
var JSONObj = { };
While representing a string value needs to be written in double quotes as follows.
[html]
{
"Product": "Splessons",
"Email": "support@splessons.com"
}
[/html]
JSON underpins numbers in double precision floating-point manner.
[html]
{
"integer": 34,
"fraction": .2145,
"exponent": 6.61789e+0
}
[/html]
JSON underpins boolean values also.
[html]
{
"first": true,
"second": false
}
[/html]
In JSON it is possible to create objects inside the another objects as follows.
[html]
{
"firstName": "Sachin",
"lastName": "Tendulkar",
"age": 37,
"address" : {
"streetAddress": "Plot-6, Mohan Nagar",
"city": "Bangra",
"state": "Mubbai",
"postalCode": "201007"
}
}
[/html]