henil_shah
7 years agoContributor
How to assert array response
[
{
"id" : "1234",
"name":"xyz"
},
"jsonfield1" : {
"jsonfield" : "xyz"
}
}
]
I got this response of my API. I dont know how to assert array.
Generally, I store in hashmap
def response_string = messageExchange.response.responseContent
def response_slurper = new JsonSlurper()
def response_hashmap = response_slurper.parseText(response_string)
assert response_hashmap.id =="123"
Its failing here since its an array.
Looking for a snippet.