In my CSV file, I have this:
id | level | date
1 | 2 | 01-01-2017
2 | 4 | 01-01-2017
After using the code from here, I am able to get this string on my console:
id,level,date
1,2,"01-01-2017"
2,4,"01-01-2017"
The code I used for the results above to be converted to JSON is from here:
var lines=csv.split("\n");
var result = [];
var headers=lines[0].split(",");
for(var i=1;i<lines.length;i++){
var obj = {};
var currentline=lines[i].split(",");
for(var j=0;j<headers.length;j++){
obj[headers[j]] = currentline[j];
}
result.push(obj);
}
However, the code results in this:
(2) [{…}, {…}]
0:{id: "1", level: "2", date: ""01-01-2017""}
1:{id: "2", level: "4", date: ""01-01-2017""}
How do I remove the additional double quotes? My desired results should be as such:
(2) [{…}, {…}]
0:{id: 1, level: 2, date: "01-01-2017"}
1:{id: 2, level: 4, date: "01-01-2017"}