JSON.parse解析遇到换行符时报错解决方法
res = JSON.parse(result.replace(/\n/g,"\\n").replace(/\r/g,"\\r"));//转义
str_o = res.result;
str_n = str_o.replace(/\\n/g,"\r\n");//解析后再转回来
本文来自博客园,作者:硅谷工具人,转载请注明原文链接:https://www.cnblogs.com/30go/p/14419426.html
res = JSON.parse(result.replace(/\n/g,"\\n").replace(/\r/g,"\\r"));//转义
str_o = res.result;
str_n = str_o.replace(/\\n/g,"\r\n");//解析后再转回来
本文来自博客园,作者:硅谷工具人,转载请注明原文链接:https://www.cnblogs.com/30go/p/14419426.html