I have a JSON array with nested objects, as below:
var cData = [{
"name": "Jack Doe",
"desc": "Jack",
"values": [{
"id": "615",
"subject": "Physics",
"Grade": "B"
}, {
"id": "616",
"subject": "Chemistry",
"Grade": "A"
}]
},
{
"name": "Jane Doe",
"desc": "Jane",
"values": [{
"id": "715",
"subject": "Maths",
"Grade": "A+"
}]
},
{
"name": "Jack Doe",
"desc": "Jack",
"values": [{
"id": "617",
"subject": "Maths",
"Grade": "A"
}]
},
{
"name": "Jane Doe",
"desc": "Jane",
"values": [{
"id": "716",
"subject": "Physics",
"Grade": "B"
}]
}]
I want to consolidate objects in above array to
var cData = [{
"name": "Jack Doe",
"desc": "Jack",
"values": [{
"id": "615",
"subject": "Physics",
"Grade": "B"
}, {
"id": "616",
"subject": "Chemistry",
"Grade": "A"
}, {
"id": "617",
"subject": "Maths",
"Grade": "A"
}]
},
{
"name": "Jane Doe",
"desc": "Jane",
"values": [{
"id": "715",
"subject": "Maths",
"Grade": "A+"
}, {
"id": "716",
"subject": "Physics",
"Grade": "B"
}]
}]
If any one has any suggestions for me it'd be really great! jQuery methods are also welcome.