暂存,待编辑
function toJson(strKeyNameList){
let str = "[[com.abc.asdfDto@ddn32142[str1=abc,str2=cde,date=May 2015,var1=<null>],com.abc.asdfDto@dab123cf[]。。。]"
// <null> -> null
let nullRegExp = /<null>/g
// ],com....Dto@12345678[ -> },{
let objRegExp = /\], com\.abc\..*@[0-9a-f]{8}[/g
// key=val ,]} -> key:val,]}
let valRegExp = /=(.*?)([,\]}])/g
// $1 = ,[{ $2 = key : ,{[ key: -> ,{[ "key":
let keyRegExp = /([,\[{])([a-zA-Z0-9]*?):/g
str = "[{" + str.substring(2);
str = str.substring(0,str.length-2) + "}]"
str = str.replace(nullRegExp,"null"}
str = str.replace(objRegExp,"},{");
str = str.replace(valRegExp,":$1$2");
str = str.replace(keyRegExp,"$1\"$2\":);
srtKeyNameList.forEach(function(key){
// = [ , { "key" : val , ] } -> [,{ "key" : "val" ,]} $1 = [,{"key": $2 = val $3= ,]}
let exp = new RegExp("([,{\[]\"" + key + "\":(.*?)([,\]})]"
str = str.replace(exp,"$1\"$2\"$3");
})
data = $.parseJson(str); //完成转Json
foreach:
data.dateKey = dateFormat(data.dateKey);
}