How do I escape backslashes in JSON? How do I escape backslashes in JSON? json json

How do I escape backslashes in JSON?


You need to escape the escape backslashes already in there :) like this:

var test = JSON.parse('{"regex":"/\\\\d+/"}');

You can test it a bit here: http://jsfiddle.net/h3rzE/