Your JSON should look like this:(您的JSON应该如下所示:)
var 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"
}];
You can loop over the Array like this:(您可以像这样遍历数组:)
for(var i = 0; i < json.length; i++) {
var obj = json[i];
console.log(obj.id);
}
Or like this (suggested from Eric) be careful with IE support(或像这样(由Eric建议)应注意IE支持)
json.forEach(function(obj) { console.log(obj.id); });
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…