我尝试循环访问下面的 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);
}
}
但由于某种原因,我只得到了第一部分,id1值。
有什么想法吗?