A. json字符串中需要转义的字符有哪些
题主记住一点,但凡会造成字符串被截断、未关闭及包裹情况的字符,就必须进行转义。
如“你好啊“小家伙””,“小家伙”外部的双引号和最外部的双引号造成了包裹;
如“你好啊“小家伙”,中间的双引号未关闭且和前后两个引号造成了混乱;
如果想进行在线调试和校验的话 可以访问网页链接进行尝试
B. C++序列化json字符串对Unicode有哪些特殊处理
根据 ECMA-404 [1] 第 7 节:
All characters may be
placed within the quotation marks except for the characters that must be escaped: quotation mark (U+0022),
reverse solis (U+005C), and the control characters U+0000 to U+001F. U+0000 至 U+001F 字符是必须转义,当中除 BS、HT、LF、FF、CR 有特殊转义符,其他都需要转义成 "\uXXXX" 的形式。
Any code point may be represented as a hexadecimal number.
所有码点可以表示为"\uXXXX" 形式。对于 U+2028 和 U+2029,[1] 并不要求转义。可能是在某些应用中有此需求(如有bug)才需要进行转义。但转义是可以的。