I am looking to iterate through a JSON object that looks like
{"key1":"val1","key2":"val2","key3":"val3"}
in a loop.
Here is my attempt:
var inobj = '[{"key1":"val1","key2":"val2","key3":"val3"}]';
var obj = eval(inobj);
for (var i = 0; i < 3; i++) {
var key = i;
var val = obj[key];
alert (key+' = '+val);
}
However, I am unsure of how to determine the length of obj
.