显示YouTube JSON中的数据

时间:2015-11-11 15:18:24

标签: jquery json

我想显示:

" subscriberCount":" 42",来自thson json文档。

$.getJSON( "https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UCgTe4gCl_pH-RNkgdcndl8g&key=AIzaSyARe-kxioXcvyS-WE3mx6Bo2fAijyG4OWo", 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( "body" );
});

如何在文档中访问subscriberCount级别?

编辑:

JSON数据如下所示:

{
 "kind": "youtube#channelListResponse",
 "etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/E7mYHJ0kZvDNIuPF1HnDg4A27lc\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": "\"0KG1mRN7bm3nResDPKHQZpg5-do/UFziElXqGi6jIN-zE5VbkSt4QvM\"",
   "id": "UCgTe4gCl_pH-RNkgdcndl8g",
   "statistics": {
    "viewCount": "18242",
    "commentCount": "1",
    "subscriberCount": "42",
    "hiddenSubscriberCount": false,
    "videoCount": "104"
   }
  }
 ]
}

0 个答案:

没有答案