So I got a string that has a backslash in it. \"kIurhgFBOzDW5il89\\/lB1ZQnmmY=\"
.
I tried adding an extra \'\\\', but JSON.stringify( \"kIurhgFBOzDW5i
The backslash is escaping the forward slash. So JSON.stringify("\/")
returns "/"
since it sees an escaped forward slash, so its just a forward slash. JSON.stringify("\\/"
) sees a backslash being escaped, and then a forward slash next to that, so it returns "\/"
. You cannot preserve the "exact" string when you stringify, since parsing a json string will not escape characters, so you get back your original data, just unescaped.