Please help me in convert in the below strings to actual data.
[
{
"key": "model1",
"values": [
"[1001874600000,16]",
"[1001961000000,11]",
"[1002047400000,14]",
"[1002133800000,19]"
]
},
{
"key": "model2",
"values": [
"[1001874600000,14]",
"[1001961000000,18]",
"[1002047400000,14]",
"[1002133800000,12]"
]
},
{
"key": "model3",
"values": [
"[1001874600000,14]",
"[1001961000000,13]",
"[1002047400000,11]",
"[1002133800000,20]"
]
},
{
"key": "model4",
"values": [
"[1001874600000,11]",
"[1001961000000,11]",
"[1002047400000,17]",
"[1002133800000,11]"
]
}
]
I used the below function to convert a flat data to the above format.
d3.csv("data.csv", function(data) {
data.forEach(function(d){
d.count = +d.count;
d.date = Date.parse(d.date);
});
var nest = d3.nest()
.key(function(d) {return d.model;})
.rollup(function(v) {return v.map(function(d) {return "[" + d.date + "," + d.count + "]";})})
.entries(data)
d3.select('body').append('pre')
.text(JSON.stringify(nest, null, ' '));
});
Now i just need to remove the double quotes in the values field. Some one please help me in this, I don't have any clue on how to do it.
Help will be much pleased.
Thanks in advance.