Table of Content

JSON syntax

How JSON Works ?

In JSON we can have 2 conventions to represent Data.

  • We can store data in JSON using two types of notations.
  • Using Array Notation we can store data in array and can easily parse data using array index.
  • Object notation creates key-value pair to store data and retrieves each record using Key.

Different Types of Notations :

  1. Object Representation
  2. Array Representation

1.Array Representation :

var language = [ "english", "hindi", "marathi" ];

We have created array of languages. Our Variable name is language.

Accessing Array :

language[0] ====>  english
language[1] ====>  hindi
language[2] ====>  marathi

thus we can have access to json array data using index and [] .

2.Object Representation :

var example = { "flower": "rose" };

In above example we have created key-value pair. we have created object example which contain “flower” as “Key” and “rose” as “Value

example =======> Name of Variable/Object
flower  =======> Key
 rose =======> Value 

How to access JSON Object :




We can represent more and more complex data structure using these JSON elements.

Example Complex Data Structure :

var author =
      "firstName": "Pritesh",
      "lastName" : "Taral",
         "title": "",
         "year": "2009"
         "title": "",
         "year": "2011"

Accessing Various Elements from JSON Object :

1. Accessing name of author :


2. Accessing Last name of author :


3. Accessing :[0].title

4. Accessing Year :[0].year

Must Read External Articles –

  2. Working on JSON objects in jQuery and MVC
  3. JSON with Java Tutorials