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
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 answers
Answer question

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 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!