What I am trying to do is simple. Parse this array holding json objects into a Javascript array.
var merchantsJson = JSON.parse('[{"id":61693,"name":"Más"},{"id":61690,"name":"\u0027\u0022\u003C/div\u003E"}]');
But the unicode character \u003C seems to be breaking the parser. In the chrome console I see "Uncaught SyntaxError: Unexpected token <"
A little more info. The above is what the code is evaluated to. In reality the code contains a jsp expression.
var merchantsJson = JSON.parse('${jsonArr}');
If I remove the single quotes, there is no issue, but eclipse give me an "missing semicolon" error message. Is it possible to parse the array with the quotes as I am trying to do?
\u
-encode troublesome characters, then there won't be a problem. – Aaron Dufour yesterday<
and>
, it's a rather safe bet that it also encodes characters that are known to break compatibility. – Juhana yesterdayjsonArr
indicates that OP has already done the stringifying, and I was not willing to assume that said stringification was aware of the intricacies of JSON vs JavaScript regarding Unicode. I see now that that is merely a misleading name. – Aaron Dufour yesterday