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

76
Views
Object to array with multiple index typescript

I have an API that return me many object like this

{ id : 1243, string: "things", bool: 1, date: "2021-21-11"}
{ id : 4233, string: "somethingselse", bool: 1, date: "2021-21-11"}

I can have many datas for the same ID as

{ id : 1243, string: "other", bool: 0, date: "2021-27-10"}
{ id : 4233, string: "somethings else again", bool: 1, date: "2021-21-11"}

So i made a function to group by id my datas to get something like

object = {
        1243: [{
            0: {
                string: "things",
                bool: 1,
                date: "2021-21-11"
            },
            1: {
                string: "other",
                bool: 0,
                date: "2021-27-10"
            }
        }]

object2 = {
    4233: [{
        0: {
            string: "somethings else again",
            bool: 1,
            date: "2021-21-11"
        }
    }]



but now i want something like this

    alldata = [{
        1243: [{
            "2021-21-11": {
                string: "things",
                bool: 1
            },
            "2021-27-10": {
                string: "other",
                bool: 0
            }
        }],
        4233: [{
            "2021-21-11": {
                string: "somethings else again",
                bool: 1,
            }
        }]
    }]

i dont know how to do this, i tried to generate arrays, object but nothing great

about 4 years ago · Juan Pablo Isaza
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!