How do I retain backslashes in strings when using JSON.stringify?

后端 未结 3 2259
忘掉有多难
忘掉有多难 2021-02-20 16:15

So I got a string that has a backslash in it. \"kIurhgFBOzDW5il89\\/lB1ZQnmmY=\".

I tried adding an extra \'\\\', but JSON.stringify( \"kIurhgFBOzDW5i

3条回答
  •  梦谈多话
    2021-02-20 16:51

    JSON.stringify doesn't remove the backslash, it encodes it. When you use JSON.parse on the other end, or whatever you do to decode your JSON, it will return the original string.

提交回复
热议问题