Gaurav Gaurav - 1 year ago 68
JSON Question

How can I iterate through following JSON object?

I have following

JSON
structure :

"123456789": {
"id": "Some_Id",
"code": "Some_Code",
"name": "Some_Name",
},
"123456789": {
"id": "Some_Id",
"code": "Some_Code",
"name": "Some_Name",
},,
"123456789": {
"id": "Some_Id",
"code": "Some_Code",
"name": "Some_Name",
}
}


Now if I have to find out name for every object inside
JSON
, how can I iterate?

Answer Source
Object.keys(theObject).forEach(function (key) {
  var item = theObject[key];
  console.log(item.name);
});