I am having trouble parsing the JSON received using WebSocket (the original question is Parse JSON received with WebSocket results with an error ). The JSON string itself is valid (verified by several JSON checks), but JSON.parse throws an exception. I am trying to figure out what it is that it cannot parse, but the only thing I get is "SyntaxError: unexpected_token ILLEGAL", it does not say where the exact position of the failed token is. Is there any way to extract such information?
Refresh . If I copy this JSON string to a static file (for example, "data.json"), then extract it and parse it using the same function (JSON.parse) - then it works fine. Therefore, I suppose that something tricky is happening, I was thinking about a newline character (maybe it was \ n instead of \ r \ n or vice versa), but completely removing all line breaks did not help. I would think that this might very well be a coding problem, but the data is received through websocket and, according to the documentation, this is utf-8 string.
2nd Update : IT WORKS is great if I use "json_parse" here: https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js Then it works great! Does this mean that this is a bug in the implementation of "JSON.parse" used by Chrome or what?
Thanks.
source share