I try to loop this json but it is not working.I want to loop through the shops but it is not working
The json:
{
"type": "shops",
"shops": {
"1": {
"id": "1",
"name": "abcd",
"open_time": "9AM",
"closed_time": "9PM"
},
"2": {
"id": "1",
"name": "efgh",
"open_time": "9AM",
"closed_time": "9PM"
}
}
}
The script
$.getJSON( "simple.json", function( json ) {
console.log( "JSON Data: " + (json) );
for(var i = 0; i < json.shops.length; i++){
console.log(json[i].shops.name);
}
});
This doesn't give me any results