JSON Sample:
{
"filename": "/files/thisWeek/YDEC-1748-000.mp3",
"client": "Consumer",
"station": "A STATION",
"ISCI": "YDEC-1748-000",
"length": 30,
"service": "RW",
"dow": "monday",
"cartNum": 9999,
"approved": "False"
}
Code:
app.get('/feed', function (request, response) {
let splatRaw = fs.readFileSync('./files/week.json')
let splatJSON = JSON.parse(splatRaw, function (key, value) {
if (value == 'RW') {
console.log(this)
}
})
response.send({ "table": splatJSON })
});
Returned Value using "RW":
{
service: 'RW',
cartNum: 9999,
approved: 'False'
}
Returned Value using "monday':
{
dow: 'monday',
service: 'RW',
cartNum: 9999,
approved:
'False'
}
I am trying to read a JSON file (about 150 entries), sample above, to pick out specific entries. My function using "this" returns different data for different keys/values used. I would like to return the full parent node, but I am unsure how to do this when the keys/values are seemingly skipped at random.