Press "Enter" to skip to content

What is JSON? the basics of JSON

This tutorials describes an overview of JSON (JavaScript Object Notation). This tutorial deals with the what is JSON, what are its features, the JSON syntax,etc.

Understanding JSON

The word JSON stands for JavaScript Object Notation. As the name shows, it can be said as the notation of javascript objects. JSON is a syntax used to store and exchange the information similar to that of XML. It is faster and easier to use JSON comparing to XML.

Sample JSON Code:

{
 "books": [
 {
 "title": "book1 Title",
 "author": "book1 Author"
 },
 {
 "title": "book2 Title",
 "author": "book2 Author"
 },
 {
 "title": "book3 Title",
 "author": "book3 Author"
 },
 {
 "title": "book4 Title",
 "author": "book4 Author"
 }
 ]
 }

The above JSON Code is equallant to the following XML code

<?xml version="1.0" encoding="UTF-8" ?>
<books>
<title>book1 Title</title>
<author>book1 Author</author>
</books>
<books>
<title>book2 Title</title>
<author>book2 Author</author>
</books>
<books>
<title>book3 Title</title>
<author>book3 Author</author>
</books>
<books>
<title>book4 Title</title>
<author>book4 Author</author>
</books>

Features of JSON:

  • JSON is said to be lightweight text-data interchange format
  • JSON is easy to understand.
  • JSON does not require a parser.
  • JSON does not have any end tags like in XML
  • JSON can use Arrays.
  • JSON is shorter than XML

JSON syntax rules:

  • JSON data is in key:value pairs.
  • Each JSON data is separated with comma.
  • The square bracket in a JSON Object can hold array
  • The curly bracket in a JSON Object can hold objects.

Parsing JSON data:

A valied JSON string can be parsed using the javascript eval() method. The data then can be accessed using the object literal notation of JavaScript as the JOSN is a subset of JavaScript