JSON stands for JavaScript Object Notation, it is just a notation format for data interchange, technically we can say its an independent data exchange format use to send or manipulate data.

Structure of JSON:

JSON data is based on key and value pairs, where key will be a string and a value may be any thing like string or numeric value or boolean etc.
JSON data is bind together in {}, opening and closing curly braces and called as JSON Object.

An Example of JSON Object:

“firstName”: “Lisa”,
“lastName”: “Ray”,
“age”: “24”,
“phone”: “865965223”,
“city”: “pune”

We can create an array of JSON objects as follows:

var somevariable=[{
“firstName”: “Lisa”,
“lastName”: “Ray”,
“age”: “24”,
“phone”: “865965223”,
“city”: “pune”
“firstName”: “Mona”,
“lastName”: “Jose”,
“age”: “20”,
“phone”: “98565223”,
“city”: “mumbai”

Here you will observe that JSON array is nothing but a group of JSON objects separated by (,) comma and enclosed in [] a square brackets.

Now a days JSON is extensively used in web development replacing XML, an another format for data interchange and that is because, it is
lighter then XML, easy to use and understand. It can be used over cross platform over cross technologies for data interchange for example we can use
JSON for PHP, javascript, ASP.net and for making desktop web application, ipads, mobiles etc. That’s the reason many web services from social platforms
provides JSON support.

JSON and Javascript:

JSON is a subset of ECME-Script, a JavaScript Specification and therefore is directly supported in JavaScript. Here is a simple example of json with

Here in the above example I am having a JSON array in which I have First Name and Last Name for two students, and using javascript DOM I showed that in html spans.


PHP supports json and provides two predefined functions to encode and decode an array to JSON. The functions are:

1. json_encode(); To encode array as JSON object.
2. json_decode(); Tod decode json object to an php array.


1, ‘b’ => 2, ‘c’ => 3, ‘d’ => 4, ‘e’ => 5);
echo json_encode($arr);


JSON with JQuery:
Jquery, one of the most popular and extensively used framework of javascript, provides full support to JSON and provides predefined functions to use it with ease.

1. jQuery.parseJSON() : Parse a JSON string.


2. jQuery.getJSON() : Load JSON-encoded data from the server using a GET HTTP request.


3.$.ajax(): to post data and get result in json format


Lastly, few core javascript functions to handle JSON:

1. JSON.stringify(); : converts an object to JSON notation representing it.


JSON.stringify(value[, replacer [, space]]);


i) assert(JSON.stringify(true) === ‘true’);
ii) assert(JSON.stringify(“foo”) === ‘”foo”‘);

2. JSON.parse(); : parses a string as JSON and returns the parsed value.


JSON.parse(text[, reviver]);


i) JSON.parse(‘true’); // true
ii) JSON.parse(‘”foo”‘); // “foo”

Hope you enjoyed the article…

Cheers!!! ūüôā

–what is json —