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

链接地址: http://www.djcxy.com/p/37864.html

上一篇: 杰克逊与JSON:无法识别的字段,未标记为可忽略

下一篇: 我是否需要为json对象转义任何字符?