I am new to json. I am having a little trouble inconverting a json from one format to another format. This is my json to be converted.
{
"message": "Successfully Advisor data has been fetched.",
"success": true,
"data": {
"dataHeaders": ["Carrier","B2B", "EM"],
"dataArray": {
"DHL": ["DHL", "45", "5","5"],
"Fedex": ["Fedex","40", "7","6"],
"UPS" : ["UPS","30", "10","3"],
"TNT" : ["TNT","30", "10","3"],
}
}
}
I require the json to be converted to this format.
[
{
"key":"Carrier",
"values":[
{
"x":"DHL",
"y":45
},
{
"x":"Fedex",
"y":40
},
{
"x":"UPS",
"y":30
},
{
"x":"TNT",
"y":35
}
]
},
{
"key":"B2B",
"values":[
{
"x":"DHL",
"y":5
},
{
"x":"Fedex",
"y":7
},
{
"x":"UPS",
"y":10
},
{
"x":"TNT",
"y":5
}
]
},
{
"key":"EM",
"values":[
{
"x":"DHL",
"y":5
},
{
"x":"Fedex",
"y":6
},
{
"x":"UPS",
"y":3
},
{
"x":"TNT",
"y":5
}
]
}
]
How can i do this using jquery?