我对 Jquery getJSON 函数有一点问题。
我的json在这里
{ "entries": [
{
"type": "status",
"SID": "X999_Y999",
"from": {
"name": "Tom Brady",
"id": "X12"
},
"message": "Json message no 1! ",
"actions": {
"UP_link": "123456",
"Comment_link": "7891011"
},
"created_time": "2010-08-02T21:27:44+0000",
"Comments": [
{
"CID": "1234",
"name": "Tom Brady",
"UID": "1234",
"Text": "My comment",
"when_comment": "2010-08-02T21:27:44+0000"
},
{
"CID": "1234",
"name": "Tom Brady",
"UID": "1234",
"Text": "My comment",
"when_comment": "2010-08-02T21:27:44+0000"
}
]
}
] }
我用这个来阅读
$.getJSON('json4test.json',
function(data) {
$.each(data.entries, function(entryIndex, entry) {
var html = '<li class="top-level">name=' + this.from.name +', comment = '+this.Comments.Text+ '</li>';
$("#results").append(html);
});
});
我实际上可以读取 this.from.name 的数组,但是为什么读取 this.Comments.Text 的结果是“未定义”。
我怎样才能正确地阅读这个?