- By converting the response as string : In this way you will get the whole response
2. By extracting the response (extract.response)
3. By using extract.path you can use certain parts of response
4.
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
- Extracting response by Json Path Class:
Json path takes string as input and then converts into JSON and helps to parse JSON.
{
"dashboard":{
"purchaseAmount":910,
"website":"rahulshettyacademy.com"
},
"courses":[
{
"title":"Selenium Python",
"price":50,
"copies":6
},
{
"title":"Cypress",
"price":40,
"copies":4
},
{
"title":"RPA",
"price":45,
"copies":10
}
]
}1. Print No of courses returned by APIJsonPath js = new JsonPath(payload.CoursePrice());
int count = js.getInt("courses.size()");2. Print Purchase Amountint totalAmount = js.getInt("dashboard.purchaseAmount")3. Print Title of the first courseString titleFirstCourse = js.get("courses[0].title");4. Print All course titles and their respective Prices5. Print no of copies sold by RPA Course
6. Verify if Sum of all Course prices matches with Purchase Amount