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

130
Vistas
Find a value in an javascript object where the amount of values varies

just scratching my head with this one. How can I extract the time remaining in seconds from the object below? Please note, the number of options varies depending on the program being run, so I somehow need to search for the "value:" associated with the "key:" "BSH.Common.Option.RemainingProgramTime".

{
"data": {
    "key": "Dishcare.Dishwasher.Program.Intensiv70",
    "options": [
        {
            "key": "BSH.Common.Option.StartInRelative",
            "value": 0,
            "unit": "seconds"
        },
        {
            "key": "Dishcare.Dishwasher.Option.HalfLoad",
            "value": false
        },
        {
            "key": "Dishcare.Dishwasher.Option.IntensivZone",
            "value": true
        },
        {
            "key": "Dishcare.Dishwasher.Option.VarioSpeedPlus",
            "value": false
        },
        {
            "key": "Dishcare.Dishwasher.Option.SilenceOnDemand",
            "value": false
        },
        {
            "key": "BSH.Common.Option.ProgramProgress",
            "value": 82,
            "unit": "%"
        },
        {
            "key": "BSH.Common.Option.RemainingProgramTime",
            "value": 1680,
            "unit": "seconds"
        },
        {
            "key": "BSH.Common.Option.RemainingProgramTimeIsEstimated",
            "value": true
        },
        {
            "key": "BSH.Common.Option.EnergyForecast",
            "value": 89,
            "unit": "%"
        },
        {
            "key": "BSH.Common.Option.WaterForecast",
            "value": 70,
            "unit": "%"
        }
    ]
}

}

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You can simply use array.find() to get the object you need.

const remainingTimeOption = myObject.data.options.find(option => option.key === "BSH.Common.Option.RemainingProgramTime");
console.log(remainingTimeOption.value);
console.log(remainingTimeOption.unit);
about 4 years ago · Juan Pablo Isaza Denunciar

0

Try this

myArray.data.options.find(x => x.key == 'BSH.Common.Option.RemainingProgramTime')[0].value;
about 4 years ago · Juan Pablo Isaza Denunciar

0

Thanks for the responses. I need to get more sleep, this was a stupid question with obvious answers, sorry.

about 4 years ago · Juan Pablo Isaza Denunciar
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