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

3e0d8f255eb05515b8a823d7c2bbf2cc.png

胡子哥哥

根据规范: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.\" }";

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值