I keep encountering an 'Uncaught SyntaxError' when attempting to parse a JSON string, and the reason behind it remains elusive.
The issue seems to be related to the fact that message
is recognized as a string, which is a known problem, even though the json structure appears to be correct. The line causing the failure in my code is var obj = ...
.
this.send = function (message) {
console.log(message);
console.log(message.toString());
console.log('{"ReadyToGo":1}');
console.log(typeof message);
var obj = $.parseJSON(message);
}
Before the error occurs, this is what I see on the console:
{"ReadyToGo":1}
{"ReadyToGo":1}
{"ReadyToGo":1}
string
Any insights or suggestions?
UPDATE: Included console.log(typeof message), returning 'string'