I currently have a JSON object that my program creates dynamically. The object is valid and can be parsed with JSON.parse().
This is the object i am working with:
{
"1":
{
"name":"temporary",
"value":"5"
},
"2":
{
"name":"temporary 2",
"value":"10"
}
}
The code i am trying to use is:
var obj = JSON.parse(StringObj);
var count = Object.keys(obj).length;
for(var i = 0; i < count; i++){
console.log(obj[i].name + ": " + obj[i].value);
}
However, this is throwing an error in the console:
obj[i] is undefined
What am i doing wrong here? ive done this a thousand times before in different applications but cant figure out why it isn't working this time.