首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法从amazon-product-api返回的JSON对象中检索字段

无法从amazon-product-api返回的JSON对象中检索字段
EN

Stack Overflow用户
提问于 2016-07-23 23:27:42
回答 1查看 55关注 0票数 0

大家好,我是新的node.js,我有这个代码`

代码语言:javascript
复制
client.itemSearch({
  keywords:'borderlands 2' ,

  searchIndex: 'VideoGames',

  responseGroup: 'ItemAttributes,Images'
}).then(function(results){
    res.end(JSON.stringify(results[0].ItemAttributes));
    var kson = JSON.parse(JSON.stringify(results[0].ItemAttributes));
    console.log(JSON.stringify(kson['Title']));

}).catch(function(err){
  console.log(err);
});`

亚马逊搜索的json结果是这个[{"Binding":["Video Game"],"Brand":["2K"],"CatalogNumberList":[{"CatalogNumberListElement":["49101"]}],"Creator":[{"_":"Take 2","$":{"Role":"Creator"}}],"Department":["Video Games"],"EAN":["0163120331895"],"EANList":[{"EANListElement":["0163120331895","0151903126141","0031111574449","0088021472273","0021113169989","0100177413464","7104254910160","0710425491016","0745449851300"]}],"Edition":["Standard"],"ESRBAgeRating":["Mature"],"Feature":["Dynamic Co-op online, split-screen and LAN: Share your adventures with friends both online and via LAN. Borderlands 2 features a seamless system enabling you to drop in and drop out of a campaign without ever having to restart the game.","World Connected Story: You will find yourself left for dead in the frozen tundra of Pandora as you begin your quest of revenge and redemption.","New Badass Gun System: An entirely new take on the groundbreaking procedural system means millions upon millions of possible weapons. The variety and style of guns in Borderlands 2 is staggering.","87 Bazillion Everything: In addition to the new gun system, you will lust after procedurally generated shields, grenades, Alien Artifacts, class mods and much, much more. And you thought the original Borderlands had a ton of loot!","Brand new environments on Pandora: Hunt through entirely brand new areas of Pandora that are more alive than ever!","Choose from all new characters and classes including the Gunzerker, who can dual-wield any two weapons in the game","Share your adventures with friends both online and via LAN with a seamless co-op system enabling you to drop in and drop out of a campaign without ever having to restart the game","Improved story integration which finds you left for dead in the frozen tundra of Pandora as you begin your quest of revenge and redemption","An entirely new take on the groundbreaking procedural system means millions upon millions of possible weapons","In addition to the new gun system, players lust after procedurally generated shields, grenades, alien artifacts, class mods and much, much more"],"Genre":["shooter-action-game-genre"],"HardwarePlatform":["Xbox 360"],"IsAdultProduct":["0"],"IsAutographed":["0"],"IsEligibleForTradeIn":["1"],"IsMemorabilia":["0"],"ItemDimensions":[{"Height":[{"_":"752","$":{"Units":"hundredths-inches"}}],"Length":[{"_":"531","$":{"Units":"hundredths-inches"}}],"Weight":[{"_":"19","$":{"Units":"hundredths-pounds"}}],"Width":[{"_":"51","$":{"Units":"hundredths-inches"}}]}],"ItemPartNumber":["710425491016"],"Label":["2K"],"Languages":[{"Language":[{"Name":["English"],"Type":["Published"]},{"Name":["English"],"Type":["Original Language"]},{"Name":["English"],"Type":["Unknown"]}]}],"ListPrice":[{"Amount":["1999"],"CurrencyCode":["USD"],"FormattedPrice":["$19.99"]}],"Manufacturer":["2K"],"ManufacturerMinimumAge":[{"_":"96","$":{"Units":"months"}}],"Model":["49101"],"MPN":["49101"],"NumberOfItems":["1"],"OperatingSystem":["Xbox 360"],"PackageDimensions":[{"Height":[{"_":"50","$":{"Units":"hundredths-inches"}}],"Length":[{"_":"750","$":{"Units":"hundredths-inches"}}],"Weight":[{"_":"20","$":{"Units":"hundredths-pounds"}}],"Width":[{"_":"530","$":{"Units":"hundredths-inches"}}]}],"PackageQuantity":["1"],"PartNumber":["49101"],"Platform":["Xbox 360"],"ProductGroup":["Video Games"],"ProductTypeName":["CONSOLE_VIDEO_GAMES"],"PublicationDate":["2012-09-18"],"Publisher":["2K"],"RegionCode":["36222"],"ReleaseDate":["2012-09-18"],"Studio":["2K"],"Title":["Borderlands 2 - Xbox 360"],"TradeInValue":[{"Amount":["86"],"CurrencyCode":["USD"],"FormattedPrice":["$0.86"]}],"UPC":["021113169989"],"UPCList":[{"UPCListElement":["021113169989","100177413464","031111574449","163120331895","088021472273","745449851300","151903126141","710425491016"]}]}]

我找不到从结果中检索字段标题的方法!

EN

回答 1

Stack Overflow用户

发布于 2016-07-23 23:54:04

试试这个:

代码语言:javascript
复制
client.itemSearch({
    keywords:'borderlands 2' ,
    searchIndex: 'VideoGames',
    responseGroup: 'ItemAttributes,Images'
}, function(err, results, response) {
    if (err) {
        console.log(err);
    } else {
         var amazon_product = JSON.parse(results[0].ItemAttributes);
         console.log(amazon_product.Title);
    }
});

我希望它能有所帮助:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38543390

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档