我是新來的JSON,我試圖返回我的Facebook相冊的列表:解析Facebook的圖形API JSON的HTML
從Facebook$(document).ready(function() {
$.getJSON("https://graph.facebook.com/me/photos?fields=id,name&access_token=MY TOKEN", function (data) {
var items = [];
$.each(data, function (key, val) {
items.push("<li id='" + key + "'>" + val + "</li>");
});
$("<ul/>", {
"class": "my-new-list",
html: items.join("")
}).appendTo(".results");
});
});
JSON:
{
"data": [
{
"id": "10150589771916817",
"name": "Mobile Uploads",
"created_time": "2012-03-03T14:47:48+0000"
},
{
"id": "41633726816",
"name": "Old pics",
"created_time": "2008-08-18T21:44:29+0000"
}
],
"paging": {
"cursors": {
"after": "NDE2MzM3MjY4MTY=",
"before": "MTAxNTA1ODk3NzE5MTY4MTc="
}
}
}
[object Object]
被退回每個項目在我的HTML。我究竟做錯了什麼?
謝謝。我知道我在閱讀json格式時會出錯。現在我明白了很多。謝謝! –
沒問題,很樂意幫忙 –
我如何在JSON中鑽取另一個級別?說出數據中是否有圖像:「data」:[「images」:[]]? –