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

141
Vistas
Dictionary in javascript that has keys associated with objects

I need to process a series of data, where each line has the user ID and the data I want to process. I thought a good solution would be to read these files and create a JSON where the keys are the ids and the values are all the data associated with that id.

[
  id1 : 
        {
          name: "..."
          age: "..."
          date_of_birth: "..."
        },
  id2 : 
        {
          name: "..."
          age: "..."
          date_of_birth: "..."
        },
  ...
]

However, I'm not sure how I can dynamically add more information to the objects associated with the ID. At each reading of the line of my file, I must look in my dictionary for the ID. If there is already a record of this ID in the dictionary, I should just add a new line in the object associated with it. Otherwise, I must create this key/value pair and add a new line to the object associated with it. Preferably, I would like to build this dictionary in descending order of ids. Any idea how I can build this structure?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

if one id can have several instances , it is better to use this structure

{
  "id1" : [
        {
          name: "name1",
          age: 1,
          date_of_birth: "date1"
        }
       ],
    
  "id2" :[ 
        {
          name: "name2",
          age: 2,
          date_of_birth: "date2"
        }
       ]
}
about 4 years ago · Juan Pablo Isaza Denunciar
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