Do I need to escape any characters for a json object?
In my code I am takign a class and converting it to JSON.
All my test is in double quotes, eg:
{ "a" : "hello world ! '' this is john's desk" }
Do I need to escape any characters when wrapped in double quotes? Is it just double quotes inside of the string I need to escape?
Yes, you can escape the quotes with "
.
Also, you can use JSON.stringify()
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
下一篇: 我是否需要为json对象转义任何字符?