JavaScript Object Notation

January 2nd, 2007 | Categories: JavaScript | Tags:

Recently I was looking at JSON (JavaScript Object Notation) and found it very intresting and usefull to me, but first let me show you how it works.

In JavaScript you need to specify data, one thig is you can do is that represent this data in xml (which you may recieve from server) like this :

[code lang="javascript"]

Muhammad Mansoor 22
http://mansoor.hadeedian.net/blog
[/code]

Now if you are want to represent the same data in JSON, you would like this :

[code lang="javascript"]
person = {
name : 'Muhammad Mansoor',
age : 22 ,
url : 'http://mansoor.hadeedian.net/blog'
}
[/code]

quite Simple, and meaningfull.

But you dont have to think of JSON as the repalcement for XML. This is the stuff that you would be primarly using only in JavaScript such as:

- Transfer Complex Objects in JS.
- Recieved JSON object in JS, so you dont have to parse it, (which you would have done if you have got XML).

The good part about JSON is that it not limited to JavaScript, you would definately find implementation of JSON in you favourite programming language, and with more than 20 implementation on JSON.org, it is really worth looking at.

Dont think of JSON as replacing XML, XML has its own grounds, and surely it does not overlaps with other standards such as XML-RPC, SOAP etc. etc.

No comments yet.
TOP