I have an array like this (each contain more than 2 key-values pairs,I just use 2 for the question)
[{"name":"Joe", "id":17}, {"name":"Bob", "id":17}, {"name":"Carl", "id": 35},{"name":"son", "id": 31},{"name":"smith", "id": 29},{"name":"tom", "id": 35}]
I would like to set a multidimensional object like this. for every DISTINC "id" and inside this "id" contain "id", "name" values .
{
'17' : {
{"name":"Joe",
"id":17},
{"name":"Bob",
"id":17}
},
'35' : {
{"name":"Carl", "id": 35},
{"name":"tom", "id": 35}
},
'31':{"name":"son", "id": 31}
},
'29':{"name":"smith", "id": 29}
}
As you see I want to assign distinct "id" as key on first object
I think I may misuse brackets, sorry for that, please correct me on this too.