Hamcrest matchers on a JSON list
QuizMediumJava onlyAsked in: Capgemini, CloudSEK, Swiggy, Wipro
The response body is:
{"items": [
{"id": 1, "name": "Asha", "address": {"city": "Pune"}},
{"id": 2, "name": "Ravi", "address": {"city": "Delhi"}}
]}
Which assertions pass? Choose all that apply.
- .body("items", hasSize(2))
- .body("items.name", hasItems("Asha", "Ravi"))
- .body("items[0].address.city", equalTo("Pune"))
- .body("items.name", equalTo("Asha"))
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.