JSON : basic introduction and references


JavaScript Object Notation


Used as a lightweight data sharing format in between server and web application, and also in between web applications.





  • This is called as fat-free version of XML :D.
  • Easy read / write format.
  • A collection of "key" : "value" pairs.
  • This can be represented as object, dictionary, hash table, keyed list or associated arrays.

As compare to XML, json



  • Don't have tags, but have hierarchy structure with some easy notations.
  • Can't use javascript keywords as names.
  • Can be parsed easily.


Notations


       Key can be of any name [String] 
                enclosed in double quotes ""

       Value can be represented as any one of the following data type like:
                Associated arrays 
                         enclosed in square brackets []
                         either key : value pairs or only values separated by comma "," 
                         can be from any one of the collection array/list/map]
                Boolean [true / false]
                Number [Int]
                Object
                String [Plain text]

       Key and value are separated by colon ":"

Sample json file -  (format - *.json)

{
  "qavalidation" : 
   {
    "url" : "http:\\www.qavalidation.com",  //object - key:value pair
    "title" : "Software QA & Validation", 
    "description" : "About software QA and Vaildation.",
    "categories" : [ "Selenium", "Testing","javaBasics" ] //values as an array
   }
}


JSON uses javascript, but any programming language can read json data as this is text only format.

JSON viewer:





References:

For pictorial representation, refer official site http://www.json.org/
For more detailed explanation, refer http://www.w3schools.com/json


Now a days most server responses comes with json format upon web application request, we can write programe to read the json data and can validate the details......

So coming to testing, we can use json data as our test data, will see details on how to read json data. [JSON parser]


No comments:

Post a Comment