c语言json加换行符,如何处理JSON中的换行符?

胡子哥哥
根据规范:http:/www.ecma-international.org/public/files/ecma-ST/ecma-404.pdfA string is a sequence of Unicode code points wrapped with quotation marks(U+0022). All characters may be placed within the quotation marks except for the
characters that must be escaped: quotation mark (U+0022), reverse solidus(U+005C), and the control characters U+0000 to U+001F. There are two-character
escape sequence representations of some characters.所以你不能通过0x0A或0x0C直接编码。这是禁止的!规范建议对一些定义良好的代码使用转义序列。U+0000到U+001F:\f represents the form feed character (U+000C). \n represents the line feed character (U+000A).正如大多数编程语言所使用的那样\对于引用,您应该转义语法(双转义-一次用于语言/平台,一次用于JSON本身):jsonStr = "{ \"name\": \"Multi\\nline.\" }";
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
