繁体   English   中英

无法访问JSON数组

[英]Trouble accessing JSON array

数据如下所示:

[
  {
    "passports": [
      {
        "identifier": "2238006043",
        "protocol": "oauth",
        "tokens": {
          "token": "2238006043-fACsU7gVtpZnkuerodfsfdsfsdfdffsfOck1R9Z",
          "tokenSecret": "BQN25aRkJcyES3yWFCa7sSpq212PKbB52Mplxpg58hICs"
        },
        "provider": "twitter",
        "user": "54e8bca1513ab1841ab6da01",
        "createdAt": "2015-02-21T17:13:05.371Z",
        "updatedAt": "2015-02-21T17:13:05.371Z",
        "id": "54e8bca1513ab1841ab6da02"
      }
    ],
    "username": "myUsername",
    "createdAt": "2015-02-21T17:13:05.362Z",
    "updatedAt": "2015-02-21T17:13:05.362Z",
    "id": "54e8bca1513ab1841ab6da01"
  },

我正在尝试从护照输出以下内容:

console.log(util.inspect(res.passports[0].identifier, { showHidden: true, depth: null }));

res是JSON对象,其中包含下面显示的数据。

尝试

console.log(util.inspect(res[0].passports[0].identifier, { showHidden: true, depth: null }));

看起来res是一个数组

res JSON对象包含项目列表。 那就是为什么它没有任何价值。 请尝试一下。

console.log(util.inspect(res[0].passports[0].identifier, { showHidden: true, depth: null }));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM