'Rest API- how to filter a response from a Json body - How to count number of people, whose age equals certain number?
I am doing a get request which returns me a large number of employees. How do I filter after a certain condition, how to count the number for the employees that are older than a certain age, in the REST API for cucumber?
e.g.
"data": [
{
"id": 1,
"employee_name": "Tiger Nixon",
"employee_salary": 320800,
"employee_age": 20,
"profile_image": ""
},
{
"id": 2,
"employee_name": "Garrett Winters",
"employee_salary": 170750,
"employee_age": 63,
"profile_image": ""
},
{
"id": 3,
"employee_name": "Ashton Cox",
"employee_salary": 86000,
"employee_age": 66,
"profile_image": ""
}]
I do not know how to count in a response from employee_age.
@Test
public void givenJson_whenParseObject_thenGetSize() {
assertThat(jsonObject)
.size() - but how to filter on the age?
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
