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

169
Views
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 answers
Answer question

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 Report

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 Report
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!