I have a JSON object that contains two arrays. I want to convert those array elements into individual elements in the JSON object.
I need this for an input into a D3 function in javascript.
My object now:
{
0:{
start:"2016-01-01",
values:[10,11,12],
names:["a","b","c"]
},
1:{
start:"2016-01-02",
values:[25,23,50],
names:["a","b","c"]
}
}
Converted object:
{
0:{
start:"2016-01-01",
a:10,
b:11,
c:12
},
1:{
start:"2016-01-02",
a:25,
b:23,
c:50
}
}
The number of variables can vary. It won't always be 3.
Any help appreciated, Thanks