jQuery, assuming a correct object
var pizzaNames=[],
data = { "pizza" : {
"pepperoni lovers":
{
"topping": "pepperoni",
"crust": "hand tossed"
},
"sausage lovers":
{
"topping": "sausage",
"crust": "hand tossed"
}
}
}
// $.each is IE8 compatible, Object.keys is not
$.each(data.pizza,function(name,val) {
pizzaNames.push(name);
});
3
solved Jquery loop through a Json object [duplicate]