Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda