I need to convert the following JSON data:
var response = {
"data": {
"List": [
{
"Name": "Mary",
"state": "AZ",
"Matriculation": "complete",
"Graduation": "complete",
"Masters": "complete",
"Phd": "notStarted"
},
{
"Name": "Stephanie",
"state": "CT",
"Matriculation": "complete",
"Graduation": "complete",
"Masters": "complete",
"Phd": "notStarted"
},
{
"Name": "John",
"state": "CT",
"Matriculation": "complete",
"Graduation": "planning",
"Masters": "notStarted",
"Phd": "notStarted"
}]
}
}
into the following using jQuery:
[
{
"state":"AZ",
"Matriculation":[
{
"Name":"Mary",
"status":"complete"
}
],
"Graduation":[
{
"Name":"Mary",
"status":"complete"
}
],
"Masters":[
{
"Name":"Mary",
"status":"complete"
}
],
"Phd":[
{
"Name":"Mary",
"status":"notStarted"
}
]
},
{
"state":"CT",
"Matriculation":[
{
"Name":"Stephanie",
"status":"complete"
},
{
"Name":"John",
"status":"complete"
}
],
"Graduation":[
{
"Name":"Stephanie",
"status":"complete"
},
{
"Name":"John",
"status":"planning"
}
],
"Masters":[
{
"Name":"Stephanie",
"status":"complete"
},
{
"Name":"John",
"status":"notStarted"
}
],
"Phd":[
{
"Name":"Stephanie",
"status":"notStarted"
},
{
"Name":"John",
"status":"notStarted"
}
]
}
]
This is what I have tried so far with zero progress. I tried to accomplish this for one state first.
This is the fiddle: http://jsfiddle.net/sqgdyk6f/
Any guidance is appreciated. I am new to JSON manipulation.
Thanks in advance!