iterate through json object jquery code example
Example 1: loop json jquery
$.map(mapArray, function(val, key) {
alert("Value is :" + val);
alert("key is :" + key);
});
Example 2: jquery loop through json
var agents = [
{
"id": "007",
"agent": "James Bond"
},
{
"id": "006",
"agent": "John Wick"
}
]
// iterate over the JSON array
$.each(agents , function(index, item) {
console.log("Agent Id: " + item.id);
console.log("Agent Name: " + item.agent);
});