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

144
Views
fetch specifi data from json and store them in array using node js / Javascript

I am trying to fetch all the log details from this json object but the problem is this key always get changed

let userJsonObject =
{
  "user_1":{
     "id":"user_1",
     "log":"de-data",
     "name":"dummy test",
     "address":"New York"
  },
  "user_2":{
     "id":"user_2",
     "log":"ex-file",
     "name":"tom",
     "address":"Nevada"
  },
  "user_3":{
     "id":"user_3",
     "log":"dis-acta",
     "name":"Jerry",
     "address":"LA"
  },
}

this is my json Object and I want fetch all the log which are present inside the json object and store them in one array like this

let gotLog= ["de-data","ex-file","dis-acta"]

here user_1 user_2 get changed everytime and I wanted to tackle this scenario and fetch all the log in one array

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

var obj = { first: 'someVal' };
obj[Object.keys(obj)[0]];

I found this here How to access the first property of a Javascript object?

about 4 years ago · Juan Pablo Isaza Report

0

let userJsonObject =
{
  "user_1":{
     "id":"user_1",
     "log":"de-data",
     "name":"dummy test",
     "address":"New York"
  },
  "user_2":{
     "id":"user_2",
     "log":"ex-file",
     "name":"tom",
     "address":"Nevada"
  },
  "user_3":{
     "id":"user_3",
     "log":"dis-acta",
     "name":"Jerry",
     "address":"LA"
  },
};


let array=[];
for(const value of Object.values(userJsonObject)){
    array.push(value.log)
};
console.log(array);

I got it :)

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!