What is JSON?
JSON (Javascript Object Notation) is a light weight data interchange format. JSON is a subset of the literal object notation in JavaScript. It can be compared to XML but parsing of JSON is very much easier than XML data. It is a text format of data and is programming language independent. In fact it very much looks like unnamed array.
Example of data in JSON
Shown below is a object declared in JSON format.
var individual = { "firstName": "Anky", "lastName": "Singh", "address": { "streetAddress": "4th Avenue", "city": "Moorpark", "state": "CA", "postalCode": 34523 }, "phoneNumbers": [ "212 555-1234", "646 555-4567" ] }; alert("The name of Individual is " + individual.firstName + " " + individual.lastName); alert("The Street Address is " + individual.address.streetAddress); alert("The Postal code is " + individual.address.postalCode); alert("First Phone Number is " + individual.phoneNumbers[0]); alert("Second Phone Number is " + individual.phoneNumbers[1]); <em>Output would be alert windows with following messages</em>: The name of Individual is Anky Singh The Street Address is 4th Avenue The Postal code is 34523 First Phone Number is 212 555-1234 Second Phone Number is 646 555-4567
Above code shows how an Individual object is declared using JSON. Alert statements provide an example how the properties of the object can be accessed in the same way as we do in C# or Java.
Being subset of literal notation JSON standard has got stricter rules. See www.json.org or RFC 4627 for a more formal description of the standard.
But all said simplicity of JSON data is the specialty of the standard.