Can';t使用javascript访问json对象

Can';t使用javascript访问json对象,javascript,jquery,json,Javascript,Jquery,Json,我知道这是一个noob问题,但我对json是新手。。。我无法访问此对象数据: { "kind": "youtube#channelListResponse", "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/7zZjjC0N0XTk8OrPCzfx2O9vPg8\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 1 }, "items": [ { "kind": "you

我知道这是一个noob问题,但我对json是新手。。。我无法访问此对象数据:

    {
 "kind": "youtube#channelListResponse",
 "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/7zZjjC0N0XTk8OrPCzfx2O9vPg8\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": "\"Y3xTLFF3RLtHXX85JBgzzgp2Enw/_uCWU9q9VCvKwgXG_6vL636QCVU\"",
   "id": "UCSWgmaFWOuYVWR8Z30n5qLQ",
   "snippet": {
    "title": "ChrisCodeX",
    "description": "Channel Features: wateva\r\n-music\r\n-gaming\r\n-comedy\r\nSubscribe to stay tune!\r\n\r\nFun Fact, to the haters out there:\r\n\r\nBeing an xbox fan isn't wrong but I hope you're being sarcastic and you realize that's a myth evolved from peoples' insistance on proving they were getting their money's worth from XBL.\r\nThe \"online connection\" is determined solely by your personal internet speeds. In other words it has nothing to do with which console you play.",
    "publishedAt": "2011-08-09T02:23:58.000Z",
    "thumbnails": {
     "default": {
      "url": "https://yt3.ggpht.com/-UL6VyOBij08/AAAAAAAAAAI/AAAAAAAAAAA/Y4oSGlkvucw/s88-c-k-no/photo.jpg"
     },
     "medium": {
      "url": "https://yt3.ggpht.com/-UL6VyOBij08/AAAAAAAAAAI/AAAAAAAAAAA/Y4oSGlkvucw/s240-c-k-no/photo.jpg"
     },
     "high": {
      "url": "https://yt3.ggpht.com/-UL6VyOBij08/AAAAAAAAAAI/AAAAAAAAAAA/Y4oSGlkvucw/s240-c-k-no/photo.jpg"
     }
    },
    "localized": {
     "title": "ChrisCodeX",
     "description": "Channel Features: wateva\r\n-music\r\n-gaming\r\n-comedy\r\nSubscribe to stay tune!\r\n\r\nFun Fact, to the haters out there:\r\n\r\nBeing an xbox fan isn't wrong but I hope you're being sarcastic and you realize that's a myth evolved from peoples' insistance on proving they were getting their money's worth from XBL.\r\nThe \"online connection\" is determined solely by your personal internet speeds. In other words it has nothing to do with which console you play."
    }
   }
  }
 ]
}
如何从缩略图默认url获取值

我试过了

$-getJSON(url, function(data){
var url = data.items.snippet.thumbnails.default.url;
});

但我得到的只是错误类型错误:data.items[0]。snippet.thumbnail未定义

对象中的
items
属性是一个数组,因此访问它时必须定义索引:

data.items[0].snippet.thumbnails.default.url

嗯,
缩略图
确实没有定义<代码>缩略图不可用。您发布的代码和您发布的消息不匹配。@FelixKling当然不匹配,因为我没有复制响应,所以我键入了它。。。但是你明白我问题的重点了,不是吗?你怎么知道smth是数组还是对象?items属性看起来像这样:
“items”:[{“kind”:“youtube#channel”,…}]
。注意外部的
[{}]
。所有其他属性仅由
{}
包装
{…}
表示对象,而
[{…}]
表示对象数组。在这种情况下,您只有一项。更多项目用逗号分隔:
[{…},{…}]
。非常感谢:*下次我会记住:)