我们将数据库导出到csv,然后使用csv文件将其还原。读取csv文件时,如
0,"SIMry",0,"ROOT",false,true,null
转换为字符串数组。
["0","SIMry","0","ROOT","false","true","null"]
Int, NULL, Boolean
都失去了意义。我希望输出
[0,"SIMry",0,"ROOT",false,true,null]
我正在使用fast-csv
节点库。
答案 0 :(得分:-1)
使用JSON.parse。例如以下代码
var a= ["0","SIMry",0,"ROOT",false,true,null];
var a_string = JSON.stringify(a); // This is what your library does
var a_json_var = JSON.parse(a_string); // This is how you compensate
console.log (JSON.stringify(a_json_var));
if (a_json_var[5]){console.log ("boolean");}
将打印
["0","SIMry",0,"ROOT",false,true,null]
boolean