我正在尝试循环遍历以下 JSON 数组:
{
"id": "1",
"msg": "hi",
"tid": "2013-05-05 23:35",
"fromWho": "hello1@email.se"
}, {
"id": "2",
"msg": "there",
"tid": "2013-05-05 23:45",
"fromWho": "hello2@email.se"
}
我尝试了以下方法
for (var key in data) {
if (data.hasOwnProperty(key)) {
console.log(data[key].id);
}
}
但是由于某些原因,我只能获取第一部分,id为1的值。
有什么想法吗?