I’m parsing JSON that is contained in an HTML element.
Consider this markup:
<div id="1">
{"string":[""\u041a\u0410\u041a""]}
</div>
And this script:
var a = $.parseJSON($("#1").html())
This will return an error (“Uncaught SyntaxError: Unexpected token \”), because the "s are converted to "s by the html() method.
How can I make jQuery not parse HTML in this case? $.text() doesn’t work either. Or am I doing something terribly wrong?
jsFiddle: http://jsfiddle.net/VJvpY/6/
EDIT: Note that the error will be displayed in the console only.
EDIT2: I need the JSON to be parsed and to create a JS object with it.
I ended up escaping all the
&s in the JSON server-side.