Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

114
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda