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

184
Visualizações
create csv from objects with different keys

I have an array of objects. Some of their keys are identical but some of them exist only in one of the object:

const data =[
{id:123, name:foo, number:25},
{id:124, name:boo, number:35, blue:8},
{id:125, name:soo, number:40, red:10}
]

I want to convert my data into a CSV, so that the headers will include all keys. if key doesn't exists in the object its value should be null , see example below:

id name number blue red
123 foo 25 null null
124 boo 35 8 null
125 soo 40 null 10

I was able to achieve this with few loops , but the code is ugly :)

Thanks!

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

0

Check if this solution applies to your problem.

Generate a csv file from a javascript array of objects

If you have any doubts in the process, just reply here. I'll try to help

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