Let's say I have a rather simple method as shown below:
var foo = function (str) {
console.log(str); //{"Field Name": "Value With "Escaped" Content"}
JSON.parse(str); //fails
}
foo('{"Field Name": "Value With \"Escaped\" Content"}');
The passed argument features intentional backslashes (the string originates from a third party), however, they're absent once the string is passed to the function (see the inline comments).
Can I avoid the issue without manually double-escaping the string? Why doesn't using single slashes around the string itself avoid this issue? Is it possible to retrieve the raw input string?