JSON Tutorial

JSON Tutorial

JSON Tutorial


JSON is a syntax for storing and exchanging data.

JSON is an easier-to-use alternative to XML.

What is JSON?

  • JSON stands for JavaScript Object Notation
  • JSON is a lightweight data-interchange format
  • JSON is language independent *
  • JSON is "self-describing" and easy to learn and understand
Note    * JSON uses JavaScript syntax, but the JSON format is text only, just like XML.
Text can be read and used as a data format by any programming language.

Below JSON example defines an customers object, with an array of 3 customer records:

JSON Example :

{"customers":[
    {"firstName":"John", "lastName":"Doe"},
    {"firstName":"Anna", "lastName":"Smith"},
    {"firstName":"Peter", "lastName":"Jones"}
]}




Below XML example also defines an customers object with 3 customer records:

XML Example:

<customers>
    <customer>
        <firstName>John</firstName> <lastName>Doe</lastName>
    </customer>
    <customer>
        <firstName>Anna</firstName> <lastName>Smith</lastName> 
    </customer>
    <customer>
        <firstName>Peter</firstName> <lastName>Jones</lastName>
    </customer>
</customers>