How to use rest assured to get the list of all the zips from the below below structure?
{
"persons":[
{
"name": "",
"age":"",
"addresses": [
{
"city": "..",
"zip": ".."
}
]
}
]
}
Expected result is List<String>
which contains zip codes only using groovy gson path.
This would work:
import io.restassured.path.json.JsonPath;
...
List<List<String>> temp = JsonPath.from(res).getList("persons.addresses.zip");
List<String> zips = temp.stream().flatMap(List::stream).collect(Collectors.toList());
System.out.println(zips);
//[..]