How to validate complete JSON response

788 views
Skip to first unread message

Abdiqani Ali

unread,
Mar 7, 2017, 7:36:04 AM3/7/17
to REST assured
Hi,

Hi everyone! Does anyone know how to loop trough the response against expected result? Like in java you can do assert.equal(response, expected);. I want to validate the whole object (key/value). Lets say i have the following response: 

[
 {
   "id": 0,
   "Age": "20",
   "FirstName": "Charlie",
   "LastName": "Smith",
   "variant": null
 },
 {
   "id": 1,
   "Age": "24",
   "FirstName": "Eddy",
   "LastName": "Murphy",
   "variant": null
 },
 {
   "id": 2,
   "Age": "30",
   "FirstName": "Eve",
   "LastName": "Kumar",
   "variant": null
 },
 {
   "id": 3,
   "Age": "40",
   "FirstName": "Will",
   "LastName": "Depp",
   "variant": null
 },
 {
    "id":4 ,
   "Age": "24",
   "FirstName": "Eddy",
   "LastName": "Murphy",
   "variant": null
 }
]

How can i validate the complete response? 

Johan Haleby

unread,
Mar 7, 2017, 7:38:16 AM3/7/17
to rest-a...@googlegroups.com
Hi,

You could try integrate with something like HamcrestJson or use Json Schema Validation

Regards,
/Johan

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abdiqani Ali

unread,
Mar 7, 2017, 7:46:40 AM3/7/17
to REST assured
Thanks for the answer. If I have a very big/long JSON response then i have to write every assertion and that is quite tiring.  
Reply all
Reply to author
Forward
0 new messages