I am trying to loop through the following:
{
\"messages\": [{
\"msgFrom\": \"13223821242\",
\"msgBody\": \"Hi there\"
}, {
\"
It appears you may just have missed the "messages" property in the data, so the loop is likely iterating the root Object rather than the Array:
for (var key in data.messages) {
var obj = data.messages[key];
// ...
}
Unless data was set to messages before the given snippet.
Though, you should consider changing that to a normal for loop for the Array:
for (var i = 0, l = data.messages.length; i < l; i++) {
var obj = data.messages[i];
// ...
}