[Solved] Jquery loop through a Json object [duplicate]


jQuery, assuming a correct object

DEMO

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]