1

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'

4

2 に答える 2

3

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

于 2015-09-08T14:36:08.773 に答える
1

Based on the documentation, this property is only available on JsonWriter and its inheritors.

于 2012-12-30T23:18:36.207 に答える