I have been attempting to restructure an existing JSON Array using AngularJS filters like $filter, but unfortunately, I am running into issues.
{
{
name: "name 1",
label: "A",
},
{
name: "name 2",
label: "A",
},
{
name: "name 3",
label: "B",
},
{
name: "name 4",
label: "B",
},
{
name: "name 5",
label: "B",
},
{
name: "name 6",
label: "C",
},
{
name: "name 7",
label: "C",
},
{
name: "name 8",
label: "C",
},
{
name: "name 9",
label: "D",
}
}
I aim to transform this array into a new one structured as follows.
{
"A" : {
{
name: "name 1",
label: "A",
},
{
name: "name 2",
label: "A",
},
},
"B" : {
{
name: "name 3",
label: "B",
},
{
name: "name 4",
label: "B",
},
{
name: "name 5",
label: "B",
},
},
"C" : {
{
name: "name 6",
label: "C",
},
{
name: "name 7",
label: "C",
},
{
name: "name 8",
label: "C",
},
},
"D" : {
{
name: "name 9",
label: "D",
}
}
}
How can I achieve this restructuring of the array using AngularJS?