var text = '{a:"aa\r\nb\r\nb",b:"33"}';
var json = eval("(" + text + ")");// 报错:未结束的字符串常量

//正确
while (text.indexOf("\r") >= 0) {
                text = text.replace("\r", "\\r");
                text = text.replace("\n", "\\n");
            }
 var json = eval("(" + text + ")");

相关文章:

  • 2022-02-07
  • 2021-12-27
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
猜你喜欢
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案