Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
JSON not returning consistent values

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!