Sample JSON
[
{
"id": "1",
"products": [
{
"id": "333",
"status": "Active"
},
{
"id": "222",
"status": "Inactive"
},
{
"id": "111",
"status": "Active"
}
]
},
{
"id": "2",
"products": [
{
"id": "6",
"status": "Active"
},
{
"id": "7",
"status": "Inactive"
}
]
}
]
I want to retrieve list of objects that have at least one active product.
Below code returns list of products but I want a list of ProdcutResponse
. Any way to do this?
response.stream()
.map(ProductResponse::getProducts)
.filter(s -> "Active".equals(s.getType()))
.collect(Collectors.toList())