2

For example we have JSON in our response:

{"data":[{"id":1,"active":false},{"id":2,"active":true}]}

By using

expect().body("data", hasItem(hasEntry("id", 1)))

we can check, if 'data' array holds element with id=1.

But how we can check, if 'data' array holds element with id=1 that is 'active' (id=1 && active=true)?

1 Answer 1

7

You can do like this:

get("/data").then().body("data.find { it.id == 1 }.active", is(true));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.