Home > DeveloperSection > Blogs > Introduction to JSON

Introduction to JSON

0 Comment(s)
 3158  View(s)
Rate this:

Introduction to JSON

JSON is smaller than XML, and faster and easier to parse. JSON (an acronym for JavaScript Object Notation) is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects. JSON is syntax for storing and exchanging text information.

JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

JSON is built on two structures:

·         A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.

·         An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

JSON is not only a syndication format (e.g. an alternative to XML); it is a language-independent data interchange format.


For AJAX applications, JSON is faster and easier than XML.

Using XML:

·         Fetch an XML document

·         Use the XML DOM to loop through the document

·         Extract values and store in variables

Using JSON:

·         Fetch a JSON string

·         eval() the JSON string

JSON Syntax Rule:

JSON syntax is a subset of the JavaScript object notation syntax.

·         Data is in name/value pairs

·         Data is separated by comma

·         Curly brackets holds objects

·         Square brackets holds arrays

Example: In this example, simply I have created JSON object and store some values after then set these values into proper names.



                <title>JSON Object Creation Demo</title>



<h2>JSON Object Creation in JavaScript</h2>


Name: <span id="jname"></span><br />

Age: <span id="jage"></span><br />

Address: <span id="jstreet"></span><br />

Phone: <span id="jphone"></span><br />


<script type="text/javascript">

                      var JsonObject= {

                                                                "name":    "Arun Kumar Singh",

                                                                "street":    "Kothapaarcha",

                                                                "age":   22,

                                                                "phone":  "000 1234567"









 Now save this file in html format and open it with web browser.

Don't want to miss updates? Please click the below button!

Follow MindStick