Let's say I have a response like below
{"errors": [{
"code": "100",
"message": "Message for 100",
},
{
"code": "200",
"message": "Message for 200",
}
]}
I can assert the codes by using JSONPath like below:
Expression: $.errors[0].code
Expected result: 100
Expression: $.errors[1].code
Expected result: 200
The problem is that the order of the objects in the array may change, i.e. 200 occurs first and 100 occurs after. So, I have to assert something like "the errros should contain an error with code 100 while the error 100 can occur anywhere in the errors array". How do I do this?
Currently, I have to use Script assertion to achieve this and I am wondering if there is a better way.
Thanks.