hurl icon indicating copy to clipboard operation
hurl copied to clipboard

Support contain check for array of objects

Open finlaydotb opened this issue 1 year ago • 1 comments

Problem to solve

Checking/asserting if an object is part of an array is not supported

I have tried

jsonpath "$" includes '{"id":"123"}'

got the error

 69 | jsonpath "$" includes '{"id":"123"}'
    |                       ^ invalid predicate value

tried

jsonpath "$" includes "{\"id\":\"123\"}"

Got the error

 69 | jsonpath "$" includes "{\"id\":\"123\"}"
    |   actual:   [object]
    |   expected: includes string <{"id":"123"}>
    |

This seems to be closer to getting it, but looks like there is a mismatch in types.

To try and get the type correct and also not to manually escape the json, I tried

jsonpath "$" includes json```{"id":"123"}```

but got the error

 69 | jsonpath "$" includes json```{"id":"123"}```
    |                       ^ invalid predicate value

So it seems if an endpoint returns an array of objects, asserting that the response contains/includes a particular object is not possible?

Proposal

Support contain check for array of objects.

finlaydotb avatar Sep 04 '23 13:09 finlaydotb