0


私はいつも同じ問題を抱えています.json投稿からの返信を読むのは難しいです.

例えば

$.getJSON('http://gdata.youtube.com/feeds/api/users/live/subscriptions?alt=json', function(data) {

  $.each(data.feed.entry, function(i, item) {

      console.log(item.feed.link.i); // did not work

   });

});

返信

{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","id":{"$t":"http://gdata.youtube.com/feeds/api/users/live/subscriptions"},"updated":{"$t":"2011-03-04T08:31:20.148Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#subscription"}],"title":{"$t":"Subscriptions of live","type":"text"},"logo":{"$t":"http://www.youtube.com/img/pic_youtubelogo_123x63.gif"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/live"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/profil ....

時々私はそれを得るのに1時間かかる -.- ...

これはなんと読みますか?何か良いアイデアはありますか?

前もって感謝します!
ピーター

4

1 に答える 1

1

Firebug コンソールに貼り付けたコードを実行すると、次のfeedオブジェクト モデルが表示されました。

ここに画像の説明を入力

ご覧のとおりfeed、 は の子ではないため item、エラーが発生しました。

代わりにこれを試してください

$.getJSON('http://gdata.youtube.com/feeds/api/users/live/subscriptions?alt=json', function(data) {

  $.each(data.feed.entry, function(i, item) {

      console.log(item.gd$feedLink); // did not work

   });

});
于 2011-03-04T08:52:17.423 に答える