Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON.parse fails in Google Chrome

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.

like image 717
theJava Avatar asked Dec 07 '22 16:12

theJava


1 Answers

Just escape it like this

var value = JSON.parse(origtext || "null");
like image 172
Oybek Avatar answered Dec 28 '22 03:12

Oybek