[Solved] JSON Objects in a JSON Array in javascript


@Amy is correct, that is not in fact valid javascript. Arrays do not have keys. So your example

[
 0:{
   columnNameProperty: "Name",
   columnValueProperty: "Nancy",
   id: "123"
 },
 1:{
   columnNameProperty: "Name",
   columnValueProperty: "Jene",
   id: "124"
 }
]

really looks like this

[
     {
       columnNameProperty: "Name",
       columnValueProperty: "Nancy",
       id: "123"
     },
     {
       columnNameProperty: "Name",
       columnValueProperty: "Jene",
       id: "124"
     }
]

If your goal is to retrieve an element by id you could make a function that loops through the array, finds and returns the object with the given id.

Alternatively, you could create a hash map and access each values by its key. So for instance, given this object:

let map = {
  "123" : {
      "Name" : "Nancy",
      "Amount" : "1000",
      "State" : "WA"
 },
  "124" : {
      "Name" : "Jene"
 }
}

You could get the value of the key “123” by saying map['123']

1

solved JSON Objects in a JSON Array in javascript