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

139
Views
How convert object list into map?

I want to convert array of objects with fields name and value into map and I have no idea how to do this. I get:

[
    {"name": "key1", "value": "value1"},
    {"name": "key2", "value": "value2"},
    {"name": "key3", "value": "value3"}
]

But I need to send in request:

[
    {"key1": "value1"},
    {"key2": "value2"},
    {"key3": "value3"}
]
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Just use Array.map:

const output = input.map(
  (row) => ({[row.name]: row.value})
);
about 4 years ago · Juan Pablo Isaza Report

0

Try this :

const arr = [
    {"name": "key1", "value": "value1"},
    {"name": "key2", "value": "value2"},
    {"name": "key3", "value": "value3"}
];

const res = arr.map((obj) => {
    return {[obj.name]: obj.value}
});

console.log(res);

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!