Digging through some project code this evening, I ran across a line of jQuery similar to this:
jQuery.parseJSON(jQuery.parseJSON(json_string)));
I was curious as to why the calls were nested. Taking a closer look at the JSON string, I found that it contained slashes (apparently escaping the quotes - this is a PHP project). The JSON string is similar to this:
"[{\"input_index\": 0, \"secondary_index\": 0, \"street_address\": \"14106 Transportation Ave\", \"last_line\": \"Kennedy Building\"}]"
I separated the calls like so:
var res1 = jQuery.parseJSON(json_string);
var res2 = jQuery.parseJSON(res1);
I found that the first call produced another JSON string, with the slashes removed, similar to this:
[{"input_index": 0, "secondary_index": 0, "street_address": "14106 Transportation Ave", "last_line": "Kennedy Building"}]
The second call to jQuery.parseJSON actually produced a javascript object.
Why does this occur? I would expect the first call to fail.
The jQuery documentation here doesn't mention behavior like this. Granted, I'm still fairly new to jQuery, so I may be missing the obvious.