[null, {
"display_with": "7",
"id": "1",
"image": "/images/salt_sugar.png",
"name": "Salt and Sugar",
"subcategories": {
"1": true,
"6": true,
"7": true
}
}, {
"display_with": "6",
"id": "2",
"image": "/images/tea_and_coffee.png",
"name": "Tea and Coffee",
"subcategories": {
"8": true,
"9": true,
"124": true
}
}]
In the above string i want 1, 6, 7 and 8, 9, 124 from second and third record respectively.
This is my logic.
recvCategories = JSON STRING
for (var j=0; j<recvCategories.length; ++j){
var category = recvCategories[j];
if (category != undefined){
var subcategories = [];
int size = Object.keys(category.subcategories).length;
for (var property in object) {
if (object.hasOwnProperty(property)) {
// do stuff
}
}
}
}
How to print 1, 6, 7 and 8, 9, 124 in // do stuff ??