Исходный код вики Сценарии
Версия 1.1 от Alexandr Fokin на 2022/07/22 17:38
Последние авторы
| author | version | line-number | content |
|---|---|---|---|
| 1 | Базовые опции: | ||
| 2 | |||
| 3 | How to customize character encoding with System.Text.Json | ||
| 4 | [[https:~~/~~/docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-character-encoding>>https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-character-encoding]] | ||
| 5 | |||
| 6 | {{code language="c#"}} | ||
| 7 | new JsonSerializerOptions() | ||
| 8 | { | ||
| 9 | //Игнорирование null элементы | ||
| 10 | IgnoreNullValues = true, | ||
| 11 | // Форматирование читаемое/компкатный | ||
| 12 | WriteIndented = true, | ||
| 13 | |||
| 14 | // Кодировка символов | ||
| 15 | //Encoder = JavaScriptEncoder.Create(UnicodeRanges.BasicLatin, UnicodeRanges.Cyrillic), | ||
| 16 | Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping, | ||
| 17 | |||
| 18 | // Enum как строка | ||
| 19 | Converters = { | ||
| 20 | new System.Text.Json.Serialization.JsonStringEnumConverter() | ||
| 21 | } | ||
| 22 | }; | ||
| 23 | {{/code}} | ||
| 24 | |||
| 25 | ---- | ||
| 26 | |||
| 27 |