I have the follwing JSON:
{
"_id":"9876567833",
"result":{
"Mercedes":[
{
"category_name":"Car"
},
{
"category_name":"Fast"
}
],
"BMW":[
{
"category_name":"Car"
}
]
}
I don't know before "Mercedes" or "BMW" (it could change, this is just for the example). I need to get "Car", "Fast", "Car".
The JSON is in categories
So I tried:
var categoArray = [];
for(var i =0; i < categories.length; i++){
for (var idx in categories[i].result) {
if (categories[i].result[idx].length > 0){
categoArray.push(categories[i].result[idx].category_name);
}
}
}
But it doesn't work.
[EDIT] It is not the same :Access / process (nested) objects, arrays or JSON
My question is much more complex
Thanks for your help!