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

175
Vistas
How to display a specific value from JSON object. Example i wanted to display the value of Low and then assign to a variable in React.js

Here is the JSON object where i wanted to display on of the values

"asset_risks": [
    {
        "Medium": 2
    },
    {
        "High": 11
    },
    {
        "Low": 3
    }
],
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

One solution is to combine all object inside the asset_risks array into a single object and then get its attribute like this:

const data = {
  "asset_risks": [
    {
      "Medium": 2
    },
    {
      "High": 11
    },
    {
      "Low": 3
    }
  ]
};

const combined = Object.fromEntries(data.asset_risks.map(Object.entries).flat());

console.log(combined);
console.log(combined.Low);

about 4 years ago · Juan Pablo Isaza Denunciar

0

Couple of ways to do that.

One way is you can make use of javascript filter. You can filter out the array based on Low and take the value from the filtered array.

Another way is to make use of find. Please check out the code below for reference.

var obj = {
"asset_risks": [
    {
        "Medium": 2
    },
    {
        "High": 11
    },
    {
        "Low": 3
    }
]
}
console.log(obj.asset_risks.find(obj => obj.Low).Low);
console.log(obj.asset_risks.filter(obj => { return obj.Low })[0].Low);

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