Json.NET(4.5.11)的最新版本包含StringEscapeHandling.EscapeNonAscii,可转义所有非ASCII字符。但是,我不知道在哪里将其作为参数传递。
如果我尝试: JsonConvert.SerializeObject(myObj, Formatting.Indented, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeNonAscii});
JsonConvert.SerializeObject(myObj, Formatting.Indented, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeNonAscii});
然后我得到编译错误: 'Newtonsoft.Json.JsonSerializerSettings' does not contain a definition for 'StringEscapeHandling'
'Newtonsoft.Json.JsonSerializerSettings' does not contain a definition for 'StringEscapeHandling'
根据文档,此属性仅在JsonWriter及其继承者上可用。