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

121
Visualizações
Coverting JSON to JavaScript Object with just values

I have some JSON where I need to convert just the values to an Object. How would I go about this?

My JSON is

[
{
  "WebsiteName": "Acme Inc.",
  "Time": "08:30:00",
  "TheDate": "2021-12-23",
  "Hits": "39"
},
{
  "WebsiteName": "Acme Inc.",
  "Time": "08:45:00",
  "TheDate": "2021-12-23",
  "Hits": "37"
}
]

and I am trying to format it like so (without the names)

var myObject = [["Acme Inc.", "08:30:00", "2021-12-23", "39"], ["Acme Inc.", "08:45:00", "2021-12-23", "37"]];

I need to do this with assuming that the code doesn't know the names. That way I can reuse the code on another JSON file without having to tweak the code each time.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Just .map it with Object.values:

let json = `[
{
  "WebsiteName": "Acme Inc.",
  "Time": "08:30:00",
  "TheDate": "2021-12-23",
  "Hits": "39"
},
{
  "WebsiteName": "Acme Inc.",
  "Time": "08:45:00",
  "TheDate": "2021-12-23",
  "Hits": "37"
}
]`;

let result = JSON.parse(json).map(e => Object.values(e));

console.log(result);

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