I have this json data
{
"default": [
[
1325876000000,
0
],
[
1325876000000,
0
],
[
1325876000000,
0
],
[
1325876000000,
0
]
],
"direct": [
[
1328196800000,
0
],
[
1328196800000,
100
],
[
1328196800000,
0
],
[
1328196800000,
0
]
],
"Sales": [
[
1330517600000,
0
],
[
1330517600000,
0
],
[
1330517600000,
91
],
[
1330517600000,
0
]
],
"Support": [
[
1332838400000,
0
],
[
1332838400000,
0
],
[
1332838400000,
0
],
[
1332838400000,
0
]
]
}
and I want to change it to this format:
data = [{
label: 'defaul',
data: the array here
}, {
label: 'name',
data: the array here
}, {
label: 'name',
data: the array here
}, {
label: 'name',
data: the array here
}];
In the past, I was doing this:
var thearray = result.default.
var theOtherArray = result.direct
...
..
and so on
It was working because I already know the name of the labels. I mean the label's name were static.
but now they are dynamic so I can't know the name of the lable.
what should I do please?
Edit
I know that I have to use
var data = [];
$.each(result, function (index, value) {
var obj = {};
obj.label = SOMETHING
obj.data = result[label]
data.push(obj);
}
but how to get the SOMETHING