【问题标题】:How do I consume Google API JSON data specifically Google Product如何使用 Google API JSON 数据,特别是 Google 产品
【发布时间】:2012-07-16 19:29:20
【问题描述】:

我在解析从 Query for products in Google Product 收到的数据时遇到问题。如果我运行类似于...的查询...

curl --header "Authorization:GoogleLogin Auth=<AuthKey>" --header "Content-Type:application/atom+xml" https://content.googleapis.com/content/v1/8076653/items/products/generic?alt=json

我收到一个 JSON(ish?) 文档,类似于以下内容

{
  "version":"1.0",
  "encoding":"UTF-8",
  "feed":{
  ...
  }
}

但是当我运行以下命令时

res.on('end', function() {
  console.log(res.body.feed);
  mainRes.send(res.body);
});

控制台显示未定义。

【问题讨论】:

  • 尝试记录 res.body 并从那里计算出结构

标签: node.js google-api


【解决方案1】:

应该是……

res.on('end', function() {
  console.log(JSON.parse(res.body).feed);
  mainRes.send(res.body);
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-09
    • 2018-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多