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

80
Vistas
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
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