Getting started with JSON

In a past few weeks, most of my projects handled involved XML manipulation and AJAX. And because of that I found an alternative to the XML which is more lightweight and can be easily used together with your DOM. Its JSON.

JSON is a data exchange format that is a subset of the object literal notation in JavaScript. It has been gaining a lot of attention lately as a lightweight alternative to XML, especially in Ajax applications. Why is this? Because of the ability in JavaScript to parse information quickly using the eval( ) function. JSON does not require JavaScript, however, and you can use it as a simple exchange format for any scripting language.

Lets take a look what JSON looks like.

{'details': {
    'id': 1,
    'type': 'book',
    'author': 'Insic2.0',
    'title': 'JSON: Getting started with JSON',
    'detail': {
        'pages': 783,
        'extra': 15,
        'isbn': 1234567,
        'price': {
            'us': 19.99,
            'ca': 19.99
        }
    }
}}

This is the equivalent in XML:


<details id="1" type="book">
<author>Insic2.0</author>
<title>JSON: Getting started with JSON</title>
<detail>
 <pages extra="15">783</pages>
 <isbn>1234567</isbn>
 <price us="19.99" ca="19.99" />
</detail>
</details>

JSON is more elegant in describing your data because of its simplicity and more lightweight.

In the next post about JSON I will be covering JSON Requests and Responses and give some examples on handling it using Zend Framework JSON library.

PG

Author: insic

Subscribe in my RSS Feed for more updates on Web Design and Development related articles. Follow me on twitter or drop a message to my inbox.

Related Post

Delicious

4 Responses to “Getting started with JSON”

  1. Hi, I am a VFX artist, I am interested in you stuff, I seriously don’t know what JSON means(it looks like a coding language),sorry but is web development a daunting task? what does it take to be a web developer,
    c ya

  2. Infaas, Thanks for dropping by. All your questions can be answered if you ask me how to become a VFX artist. I dont even know what VFX means. Cheers!

  3. Hi insic,

    I agree with you, JSON is more simple and lightweight. I’m a web developer and I’m learning some stuff about jquery and web 2.0.
    I will start learning how to process JSON using your tutorials, which are very good.

    PS: you look cute in your photo.

  4. Buen post para iniciar con JSON.

Leave a Reply