JSON – Javascript Object Notation

There were days when we used to create and use XML for transporting and store data and it was good at it. But I consider there was a problem with it getting data from it, I feel nausea. I used ‘was’ here because I also consider it as the way our daddies used to transfer data. Now is the day of JSON.

JSON is cool, easy, requires less memory(though we are not bothered). You can use it with any language and I love it. Frankly, I gave up XML before learning it because of JSON.

JSON looks like array we make in C\C++ or any other language. As we are familiar with the array, it makes understanding of JSON easy. It looks like :

{'data' : ['J','S','O','N'], 'this' : { 'is' : 'json' } };

Let’s use it with PHP and Javascript.


$array = new array('data'=>array('J','S','O','N'), 'this'=>'json');
$json = json_encode($array);
$json = json_decode($json);
echo $json->data[0];
//output: J
echo $json->this;
//output: json


var json = {'data' : ['J','S','O','N'], 'this' : { 'is' : 'json' } };
//output: J
//output: J
//output: json
//output: json

We have studying here for PHP and Javscript as it is used mostly for web development. Go to json.org for better understanding and using with other languages.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: