iterate through json objects javascript code example
Example 1: how to iterate a json object in javascript
var obj = {a: 1, b: 2};
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
var val = obj[key];
console.log(val);
}
}
Example 2: loop though json object in javascript
var p = {
"p1": "value1",
"p2": "value2",
"p3": "value3"
};