I have a JavaScript array with any number of nodes with subCategories as the below format.
{
"maDetails": [{
"categoryId": 1,
"category": "Third Party Applications",
"subCategories": [{
"categoryId": 5,
"category": "Third Party Applications6",
"subCategories": [{
"categoryId": 3,
"category": "BMC Remedy"
}]
}]
},
{
"categoryId": 1,
"category": "Third Party Applications",
"subCategories": [{
"categoryId": 3,
"category": "Third Party Applications2",
"subCategories": [{
"categoryId": 3,
"category": "BMC Remedy"
}]
}]
}
]
}
The subCategories may be any number. I want to map all the subcategories to a single array with its parent category name and ID. what is the easiest way to do that?