Currently, I am facing an issue while troubleshooting an error on a client's website that only seems to occur on iOS 10 devices. The clients have mentioned that it was working fine prior to upgrading their devices to iOS 10 and reverting back to iOS 9 eliminates the error. It seems like the problem is related to JSON.parse and local storage data (this.local[i]). Please see below for details on the javascript error, sample data, and JavaScript snippet.
Javascript Error:
[Error] SyntaxError: JSON Parse error: Unexpected identifier "function"
parse (Locus.js:40)
Data sample: (this.local)
[{"ObservationID":"444","Username":"blah","Deleted":0,"Flagged":0},
{"ObservationID":"555","Username":"blah","Deleted":0,"Flagged":0}]
Javascript:
Locus.prototype.loadFromLocal = function () {
if (this.local) {
for (var i in this.local) {
var len = ('' + this.local[i]).split('{').length;
if (len != 1) {
this.data[i] = JSON.parse(this.local[i]);
}
else {
if (parseFloat(this.local[i]) == this.local[i]) {
/* local storage is a number */
this.data[i] = parseFloat(this.local[i]);
}
else
{
/* already parsed */
this.data[i] = this.local[i];
}
}
}
}