My API responds my call with the following JSON structure:
[
{
"order": {
"total": "240.0",
"completed_at": 1358432545000
}
},
{
"order": {
"total": "720.0",
"completed_at": 1359474090000
}
}
]
However, I want this JSON to be structured like this in order to use my data in Flot Graphs:
{
"label":"Order",
"dataBar":[
[
1358432545000,
240.0
],
[
1325635200000 ,
720.0
]
]
}
I've tried the following code, but it returns all data with comma separated, without '[' and ']'
var flotData = $.map(API_Response, function(i){ return [i.order.completed_at, parseInt(i.order.total)] });
How should I do that?