I'm getting an 'Uncaught SyntaxError' while trying to parse a JSON string, and I can't figure out why.
It looks like message
is a string, which seems to be a common problem, and the json appears to be valid. A snippet of my code is given. It fails on the var obj = ...
line.
this.send = function (message) {
console.log(message);
console.log(message.toString());
console.log('{"ReadyToGo":1}');
console.log(typeof message);
var obj = $.parseJSON(message);
}
On the console, I get this just before the error.:
{"ReadyToGo":1}
{"ReadyToGo":1}
{"ReadyToGo":1}
string
Any ideas?
EDIT: Added console.log(typeof message), which yields 'string'