Google Chrome中的JSON.parse失败 [英] JSON.parse fails in Google Chrome

查看:256
本文介绍了Google Chrome中的JSON.parse失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var origtext = Aes.Ctr.decrypt(recentPatientsFile.read()。text,'L0ck it saf3',256); 
var recentPatientsList = JSON.parse(origtext);

在执行警报(origtext)时,我收到空的数据。 JSON.parse(空数据)在其他浏览器中工作正常,但在谷歌浏览器中,我得到未捕获的SyntaxError:意外的输入结束。当我删除JSON.parse()时,那么一切似乎都没有问题。

>

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


var origtext = Aes.Ctr.decrypt(recentPatientsFile.read().text, 'L0ck it up saf3', 256);
var recentPatientsList = JSON.parse(origtext);

while doing an alert(origtext), i get empty data. The JSON.parse(empty data) works fine in other browsers, but in google chrome i get Uncaught SyntaxError: Unexpected end of input . When i remove the JSON.parse(), then everything seems to be fine.

解决方案

Just escape it like this

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

这篇关于Google Chrome中的JSON.parse失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆