我有以下JSON对象:
[ { "comments": [ { "created_at": "2011-02-09T14:42:42-08:00", "thumb": "xxxxxxx", "level": 1, "id": 214, "user_id": 41, "parent_id": 213, "content": "<p>xxxxxx</p>", "full_name": "xx K" }, { "created_at": "2011-02-09T14:41:23-08:00", "thumb": "xxxxxxxxxxxxx", "level": 0, "id": 213, "user_id": 19, "parent_id": null, "content": "<p>this is another test</p>", "full_name": "asd asd asd asd asd" } ], "eee1": "asdadsdas", "eee2": "bbbbb" } ]
这是来自一个$.ajax请求,我有成功。
$.ajax
success: function (dataJS) { console.log(dataJS); console.log(dataJS[eee1]); console.log(dataJS.comments); }
问题是,即使dataJS在控制台中正确显示,我也无法访问JSON对象中的项目。有想法吗?
那是因为您的基础对象也是数组。
console.log(dataJS[0].comments[0]);
我怀疑那会有用