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

156
Views
how to map a json object into another new object

i have a payload response which goes like:

"requirementDetails": {
            "requirementId1": "A",
            "requirementId2": "B",
            "requirementId3": "C",
            "requirementId4": "D",
            "requirementId5": "E",
            "requirementId6": "",
            "requirementId7": "",
            "requirementId8": "",
            "requirementId9": "",
        }

and i want to create new array of the requirements which will not take the blank requirements using javascript map function and i want the resultant array to look like this:

data = [ "A","B","C","D","E"]

can anybody please help me out.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can get all values using Object.values and then you can filter it

const payload = {
  requirementDetails: {
    requirementId1: "A",
    requirementId2: "B",
    requirementId3: "C",
    requirementId4: "D",
    requirementId5: "E",
    requirementId6: "",
    requirementId7: "",
    requirementId8: "",
    requirementId9: "",
  },
};

const data = Object.values(payload.requirementDetails).filter(Boolean);

console.log(data);

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!