Is jQuery.parseJSON able to process all valid json?

Posted by murze on Stack Overflow See other posts from Stack Overflow or by murze
Published on 2010-04-02T12:32:44Z Indexed on 2010/04/02 12:33 UTC
Read the original article Hit count: 488

Filed under:
|

This piece of valid json (it has been generated using php's json_encode):

{"html":"form is NOT valid<form id=\"articleform\" enctype=\"application\/x-www-form-urlencoded\" method=\"post\" action=\"\"><dl class=\"zend_form\">\n<dt id=\"title-label\">&nbsp;<\/dt>\n<dd id=\"title-element\">\n<input type=\"text\" name=\"title\" id=\"title\" value=\"Artikel K\"><\/dd>\n<dt id=\"articleFormSubmitted-label\">&nbsp;<\/dt>\n<dd id=\"articleFormSubmitted-element\">\n<input type=\"hidden\" name=\"articleFormSubmitted\" value=\"1\" id=\"articleFormSubmitted\"><\/dd>\n<dt id=\"submit-label\">&nbsp;<\/dt><dd id=\"submit-element\">\n<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Bewaar artikel\" onclick=\"this.value='Bezig...';\"><\/dd><\/dl><\/form><script type=\"text\/javascript\">\n\t $(\"#articleform\").submit(function(){\n $.post(\"\/admin\/ajax\/contenttree\/node\/9\/ajaxtarget\/ajaxContainer\", $(\"#articleform\").serialize(), function(html){$(\"#ajaxContainer\").html(html);} );\n\t\t return false;\n\t });\n\n <\/script>","newNodeName":""}

is giving

jQuery.parseJSON(data)

and me a hard time.

With this piece of code:

alert('start');
alert(data);
jQuery.parseJSON(data)
alert('stop');

I get a message start and then the data (jsonstring above) is shown. The message "stop" never appears.

When I use this json:

{"html":"test","newNodeName":""}

I've verified that my first big chick of json is valid. Why isn't it processed by jQuery.parseJSON Are there any special characters that don't go well with json?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JSON