Say that you have the following jsonObject
var arrayWithValuesAndGroups = [{
"TestObject": "Object1",
"GraphGroup": {
"Test": {
"Group": "A",
"Value": "6"
},
"Test2": {
"Group": "B",
"Value": "5"
}
}
},
{
"TestObject": "Object2",
"GraphGroup": {
"Test": {
"Group": "A",
"Value": "9"
},
"Test2": {
"Group": "B",
"Value": "12"
}
}
},
{
"TestObject": "Object3",
"GraphGroup": {
"Test": {
"Group": "A",
"Value": "99"
},
"Test2": {
"Group": "B",
"Value": "16"
}
}
}
]
I want to create a new object with all groups and all values that have that group should be in that array. For example I want the above object to be converted into the bellow
{
"A": {
"Test1": {
"0": "6",
"1": "9",
"2": "99"
}
},
"B": {
"Test2": {
"0": "5",
"1": "12",
"2": "16"
}
}
}
What strategy would you use?