As a part of End to End REST Assured Tutorial , in this post We will learn about “JSON”.

JSON stands for “JavaScript Object Notation” which is a lightweight , language independent and self describing format in text for data storing and interchange. JSON is easy to read, write and create for humans which makes it famous over XML.

JSON was derived from JavaScript but now it is supported by many languages. A file containing JSON is saved using “.json” extension.

When we want to create a new resource or say want to add a new student details in to a student database, we need to send a POST request with a payload to API end point. This payload can be a JSON format. So , JSON is majorly used to exchange data between Web Server and Client.

An example JSON is below:-

As you see above, JSON stores data as a key-value pair. Key is left side and value is right side and a semi colon is used to separate both. One key-value pair is separated with another key-value pair using comma (,).

A key is always a string and a string must be enclosed in double quotes. A value can be a string, number ( With decimal and without decimal ), a Boolean ( true and false) , an object , an array or a null.

JSON can be found in two formats :- JSON Object and JSON Array. Example shown above is a JSON Object. Below is a JSON Array:-

A JSON Object is an unordered data structure which starts with opening braces ( ‘{‘) and ends with a closing braces (‘}’). A JSON Array is a ordered collection which starts with opening bracket ( ‘[‘) and ends with a closing bracket(‘]’). A JSON array consists of values separated by comma. A JSON array can be hold multiple JSON Objects as well.

Example:-

Above JSON contains example for all possible types of values. Key “Mob” is a JSON array of strings while “Address” key is a JSON array of JSON Objects. “isMarried” key holds a boolean value. Key “techSkills” holds a JSON Object. Key “hobbies” holds a null value. “NULL” in place of “null” will give an error.

There are multiple websites which you can use to create and validate JSON easily.

Json Editor Online

Live JSON Generator

You can clone/download example repo here.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappyLearning

You can find all Selenium related post here.
You can find all API manual and automation related posts here.
You can find frequently asked Java Programs here.

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply