JS中将[["123","456","789"],[["123","456","789"],[["123","456","789"],[["123","456","789"]...] 格式的转换成二维数组
function jsonToArr(jsonData) {
var jsonsString = jsonData.slice(1, jsonData.length - 1);
var jsonStrings = jsonsString.split("],")
var length = jsonStrings.length;
for (var i = 0; i < length-1; i++) {
jsonStrings[i] += ']';
}
var source = [[length]];
for (var j = 0; j < length; ++j) {
var oneObj = jsonStrings[j].replace(/"/g,'')
.replace('[','')
.replace(']','')
.split(",");
source.push(oneObj);
}
return source;
}
JS中替换和分割方法的使用。
jsonStrings.replace(/"/g,'')
.replace('[','')
.replace(']','')