Nom*_*Nom 2 javascript json node.js
我正在尝试使用node.js解析JSON API响应.我把所有东西都放下了但是在某一点上(这必须很简单),我完全坚持如何接近子阵列或其他东西.
这是我想要完成的一个例子.(忽略TF2主题)
"AWPer Hand":
{
"defindex": [851],
"prices": {
"1": {
"Tradable": {
"Craftable": [{
"value": 15.33,
"currency": "metal",
"difference": -0.33,
"last_update": 1469842566,
"value_raw": 15.33
}]
}
},
"6": {
"Tradable": {
"Craftable": [{
"value": 3,
"currency": "metal",
"difference": 0.17,
"last_update": 1466442983,
"value_raw": 3
}]
}
},
"11": {
"Tradable": {
"Craftable": [{
"value": 5,
"currency": "keys",
"difference": -4.75,
"last_update": 1469371613,
"value_raw": 102.475
}]
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
它不是正确的格式,因为文件中有很多内容,但要获得它看起来大多数的格式我有这行代码可行
var obj = JSON.parse(data);
var price = obj['response']['items'][itemName]['prices'][quality]['Tradable']['Craftable']
Run Code Online (Sandbox Code Playgroud)
(示例响应将是病房的[itemName])
在craftable里面有一个方括号周围的子数组,我如何在node.js中正确解析它以获得"value_raw"ID?
感谢您的时间!
| 归档时间: |
|
| 查看次数: |
3549 次 |
| 最近记录: |