Answer the question
In order to leave comments, you need to log in
How to parse json file in node js?
Here is the part of the json file where I need to take for example name and op so I write like this
var fs = require("fs");
var contents = fs.readFileSync("priceData.json");
var jsonContent = JSON.parse(contents);
console.log(jsonContent.name);
PS C:\Users\Eugene\Desktop\steam-trade> node bot
undefined
{ name: 'AK-47 | Red Laminate (Field-Tested)',
s7d: [ 1030, 59 ],
op: [ 671, 255 ],
bs: [ 699, 72 ],
bsb: [ 594 ],
tm: [ 429, 81 ],
JARD: [ 0, 0 ],
roll: [ 1015, 31 ],
csm: [ 1125, 4 ],
css: [ 0, 0 ],
csw: [ 0, 0 ],
ts: [ 1040, 2 ],
jar: [ 0, 0 ],
me: [ 0, 0 ],
gg: [ 0, 0 ],
rt: [ 0, 0 ],
skts: [ 0, 0 ],
de: [ 0, 0 ],
su: [ 0, 0 ],
Answer the question
In order to leave comments, you need to log in
Your JSON is not valid.
In JSON, all keys are strings.
{ "name": "AK-47 | Red Laminate (Field-Tested)",
"s7d": [ 1030, 59 ],
"op": [ 671, 255 ],
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question