Why does the jQuery JSON parser need double escaping for backslashes?

Viewed 15580

I have trouble wrapping my head around a peculiar feature of the JSON data format.

The situation is as follows: I have a string containing a Windows (sigh) directory path, backslashes escaped. For some reason, the jQuery JSON parser thinks that a single escape is not enough.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">

var success = jQuery.parseJSON('{"a":"b:\\\\c"}');
var failure = jQuery.parseJSON('{"a":"b:\\c"}');

</script>

Can anyone explain what makes such double escaping necessary?

1 Answers
Related