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

113
Visualizações
How to insert array data into json object in react js

I have a languages array. I need to insert my array data into Json Objeatc within a function. I am a new student and I tried to do this using map. But it only inserts one data of array into a JSON object. But I need to insert all off array data one by one. But I don't know the way to that.IF anyone can help me with that it's really mean to me. Thank you.

This is how I need to be my JSON object:-

"displayNameLocalization": {
  "en": "Fruits",
  "fr": "des fruits",
  "ja": "果物"
}
const data = {
  displayNameLocalization : {},
};

const languages = ['En', 'Ta', 'Fr'];

function testFinalValue() {
  displayNameLocalization.map((item) => {
    data.displayName = item;
  });   
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

that's because you are overwritten the same variable in each loop of map, because there will be one element in data with name displayName , so in each loop you are affecting w new value to the same element that's why you input has just one value affected. Can you afford an example of the input and the output that you want to get so I can help you with the code.

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