Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

106
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda