Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!