【问题标题】:JSON.parse fails in Google ChromeJSON.parse 在 Google Chrome 中失败
【发布时间】:2012-02-27 20:13:19
【问题描述】:
var origtext = Aes.Ctr.decrypt(recentPatientsFile.read().text, 'L0ck it up saf3', 256);
var recentPatientsList = JSON.parse(origtext);

在执行alert(origtext) 时,我得到空数据。 JSON.parse(empty data) 在其他浏览器中运行良好,但在 google chrome 中我得到 Uncaught SyntaxError: Unexpected end of input 。当我删除 JSON.parse() 时,一切似乎都很好。

【问题讨论】:

    标签: javascript json google-chrome


    【解决方案1】:

    就这样逃避吧

    var value = JSON.parse(origtext || "null");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-19
      • 2015-08-29
      相关资源
      最近更新 更多