I'm trying to read the following json file into node js :
myData.json
[
{"1000000": {
"name": "ALEX",
"intern": false,
"purchase": 76
}},
{"2000000": {
"name": "KELVIN",
"purchase": false,
"days": 46
}},
{"3000000": {
"name": "PUTIN",
"intern": false,
"purchase": 9
}}
]
var fs = require('fs');
var obj = JSON.parse(fs.readFileSync('./flatSearch.json', 'utf8'));
console.log("Name is " + obj[0]);
Output:
{ '1000000' : { "name": "ALEX", "intern": false, "purchase": 76 }}
What I need is :
1) I need just the name or the intern value or purchase value
2) I need just the value 1000000
Could someone help me on how can I fetch these values in node JS ?