Im trying to iterate over an array of json file objects to access the keys and values of its variables and add them to the list of elements using jquery getjson and each.
I think the solution should be similar to the solution in this article ... but I can not get it to work and show results in general ... Any help would be greatly appreciated!
JQuery sorting through a json array
$.getJSON('data/file.json', function(data)
{
var data = [];
$(data).each(function(idx, obj)
{
$(obj).each(function(key, value)
{console.log(key + ": " + value);}
}
}
);
Json data is formatted as follows:
[{
"name": "Name",
"street_address1": "XYZ Road",
"street_address2": null,
"city": "New York",
"zip": 10038,
"phone": 2122222222 ",
"description ": "About xyz..."
},
{ next listing... }]
And html should be formatted as follows:
Name: Name
Address: XYZ Road
Floor #2
City, State 10001
Description: About xyz...
source
share