I want to loop through the JSON I have below with the given JavaScript
{
"jsonUrl": "/testUrl",
"data": {
"country":"US",
"company":"ABC",
"items":[
{
"id": "1",
"id2": "12345",
"total": 1
},
{
"id": "2",
"id2": "23456",
"total": 2
}
]
}
}
I've tried the following but I've had no luck.
for (var key in json) {
if (json.hasOwnProperty(key)) {
alert(json[key]);
}
}
When doing this, the alert displays [object][object]
. I don't get the actual data inside the object.