Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The latest release of Json.NET (4.5.11) contains StringEscapeHandling.EscapeNonAscii, which escapes all non ASCII chars. But, I can't figure out where to pass it as a parameter.

If I try:
JsonConvert.SerializeObject(myObj, Formatting.Indented, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeNonAscii});

then I get compile errors:
'Newtonsoft.Json.JsonSerializerSettings' does not contain a definition for 'StringEscapeHandling'

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
226 views
Welcome To Ask or Share your Answers For Others

1 Answer

On more recent versions of Newtonsoft.Json this is available on JsonConvert.SerializeObject(). Pass a JsonSerializerSettings instance where StringEscapeHandling is StringEscapeHandling.EscapeNonAscii.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...