在对含特殊字符JSON数组字符串转换成json对象时报语法错误,无论用eval还是JSON.parse都没用,
谷歌、IE9都没问题,通过debugger发现是因为字符串中含特殊字符导致前台报语法错误
theString = theString.Replace(">", ">");
theString = theString.Replace("<", "<");
theString = theString.Replace(" ", " ");
theString = theString.Replace("\"", """);
theString = theString.Replace("\'", "'");
theString = theString.Replace("\\", "\\\\");//对斜线的转义
theString = theString.Replace("\n", "\\n");
theString = theString.Replace("\r", "\\r");
除了以上方法还有其它方法?因为转成对象之后 还得转回去
跪求大神指导
。。在Html直接引用这个文件就行了?
追答对的
本回答被提问者采纳