Validation By Partial Json
Partial Json Validation
We can verify partial json body using Json Path
Format:
jsonPath:jsonbody(json body)
_VERIFY.JSON.PART_ .book[?(@.author =~ /.*REES/i)]:jsonbody( [ { "category" : "reference", "author" : "Nigel Rees", "title" : "Sayings of the Century", "price" : 8.95 } ])
Json Path:
.book[?(@.author =~ /.*REES/i)]
Json Body:
[ { "category" : "reference", "author" : "Nigel Rees", "title" : "Sayings of the Century", "price" : 8.95 } ]
Use http://jsonpath.herokuapp.com/ web app to validate your json query

Test File Implementation
At Expected Response column, add the jsonbody validation as follows
Example found at apiTestData -> testCases -> TestCases_UserValidation.csv (row 3)

Path Examples
JsonPath (click link to try)
Result
The authors of all books
All authors
All things, both books and bicycles
The price of everything
The third book
The second to last book
The first two books
All books from index 0 (inclusive) until index 2 (exclusive)
All books from index 1 (inclusive) until index 2 (exclusive)
Last two books
Book number two from tail
All books with an ISBN number
All books in store cheaper than 10
All books in store that are not "expensive"
All books matching regex (ignore case)
Give me every thing
The number of books
Last updated
Was this helpful?