Take out particular array out of nested object in javascript I have a nested object:
INPUT:
{
"countryList": [
{
"label": "Australia",
"id": "555",
"productHierarchy": "ABC",
"locked": "true",
"products": [
{
"id": "342",
"label": "342- Test",
"description": "Test"
},
{
"id": "123456",
"label": "123456- Test",
"description": "Test"
}
]
},
{
"label": "Brazil",
"id": "888",
"productHierarchy": "XYZ",
"locked": "true",
"products": [
{
"id": "987",
"label": "987- Test",
"description": "Test"
},
{
"id": "567",
"label": "567- Test",
"description": "Test"
}
]
}
]
}
From this object I want an array of products according to countryList label.
OUTPUT
If I give country label as Australia
I want:
products= [
{
"id": "342",
"label": "342- Test",
"description": "Test"
},
{
"id": "123456",
"label": "123456- Test",
"description": "Test"
}
]
Please help me out solving this.