Sunday, May 24, 2009

JSON an easy example, get start with JSON, how to use JSON

JSON : JavaScript Ojbect Notation.

It contains name/value pairs, array and other object for passing aroung ojbect in java script. It is subset of JavaScript and can be used as object in javascript.

You can use JSON to store name/value pair and array of ojbect.

It has eval() method to assign value to variable.
In below example, I have put all things together.
Just make one html file and you can start your practice on it.

How to use this tutorial:
1. Make one file JSONDemo.html
2. And paste below code

<script language="javascript">
eval("var amount =10;");
alert("Value of amount :: "+amount);

var student = {
name : "Binod",
roll : 110,
subject : ["Java","Database","Networking"]

alert("Student Name :: ";
alert("Student All Subject :: "+student.subject);
alert("Student First Subject :: "+student.subject[0]);
alert("Student No. of Subject :: "+student.subject.length);

for(var i=0;i<student.subject.length;i++){
var value = student.subject[i];

var person = {
name : "Ambani",
books : [
title : "Java Programming",
author : "Binod Suman"
title : "XML",
author : "Don Box"


alert("Book Title :: "+person.books[0].title);
alert("Book Author :: "+person.books[0].author);


Please put your comment on this post for enhance this blog or this tutorial.

Thanks and have a nice day ............ :)


  1. It's nice example.But my question is that why we use JSONObject and JSONArray instead of Map interface.

  2. We can use JSON object in javascript as there is no native support for Maps inteface within Javascript. You can visit this link

    - Parag MPS US

  3. json is a very interesting language to be used. very good tutorial and can hopefully help me in building json in the application that I created for this lecture. thank you

  4. I tried this but not working..............why?

  5. Its been seen a lack of explanation in the example.
    please provide few standard example which is used around the IT industries and please dont copy paste from other web site.


You can put your comments here (Either feedback or your Question related to blog)