【发布时间】:2017-06-24 02:23:49
【问题描述】:
在 json 文件中我有这个
{
"Class Token - Scout": {
"defindex": [5003],
"prices": {
"3": {
"Tradable": {
"Craftable": [{
"value": 244,
"currency": "keys",
"difference": 266,
"last_update": 1339261330
}]
}
},
"6": {
"Tradable": {
"Craftable": [{
"value": 0.16,
"currency": "metal",
"difference": 0.05,
"last_update": 1341200357
}]
}
}
}
}
}
我的代码是
//The price of an item
const price = require('./price.json')
//Things i have
var item = 'Class Token - Scout'
if(item == price){
console.log(price.defindex)
console.log(price.prices.6.Tradable.Craftable.value)
}
我希望它在 price.json 文件中搜索项目名称是否存在,如果它返回项目的定义索引和值
【问题讨论】:
-
item 是一个字符串,price 是一个对象,它们永远不会是
== -
那我该怎么办,我是 js 新手,想不通
标签: javascript json node.js steam