如何连接code在JSON.NET单引号/撇号 [英] How to encode the single quote/apostrophe in JSON.NET
本文介绍了如何连接code在JSON.NET单引号/撇号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何连接code中的
到 \\ u0027
与JSON.NET?
这样的JSON字符串会是这个样子:
{ID:8,公司名称:简\\提供上门面包店}
解决方案
样品呼叫
Newtonsoft.Json.JsonConvert.SerializeObject(your_object,
Newtonsoft.Json.Formatting.None,
新Newtonsoft.Json.JsonSerializerSettings
{StringEscapeHandling = Newtonsoft.Json.StringEscapeHandling.EscapeHtml})
How to encode the '
to \u0027
with JSON.NET?
So that the json string would look something like this:
{"Id":8,"CompanyName":"Jane\u0027s bakery"}
解决方案
Sample Call
Newtonsoft.Json.JsonConvert.SerializeObject(your_object,
Newtonsoft.Json.Formatting.None,
new Newtonsoft.Json.JsonSerializerSettings
{ StringEscapeHandling = Newtonsoft.Json.StringEscapeHandling.EscapeHtml })
这篇关于如何连接code在JSON.NET单引号/撇号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文