diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2021-08-18 02:46:59 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-18 02:46:59 -0400 |
| commit | 72d3f7020ad80ce1a53eeae8c5d57abeb22a4679 (patch) | |
| tree | dd43e663838cdc7d99a4af565523df58ae23c856 /MediaBrowser.Common/Json/JsonDefaults.cs | |
| parent | 7aef0fce444e6d8e06386553ec7ea1401a01bbb1 (diff) | |
| parent | e5cbafdb6b47377052e0d638908ef96e30a997d6 (diff) | |
Merge branch 'master' into patch-2
Diffstat (limited to 'MediaBrowser.Common/Json/JsonDefaults.cs')
| -rw-r--r-- | MediaBrowser.Common/Json/JsonDefaults.cs | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/MediaBrowser.Common/Json/JsonDefaults.cs b/MediaBrowser.Common/Json/JsonDefaults.cs deleted file mode 100644 index 9d30927db..000000000 --- a/MediaBrowser.Common/Json/JsonDefaults.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Text.Json; -using System.Text.Json.Serialization; -using MediaBrowser.Common.Json.Converters; - -namespace MediaBrowser.Common.Json -{ - /// <summary> - /// Helper class for having compatible JSON throughout the codebase. - /// </summary> - public static class JsonDefaults - { - /// <summary> - /// Gets the default <see cref="JsonSerializerOptions" /> options. - /// </summary> - /// <remarks> - /// When changing these options, update - /// Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs - /// -> AddJellyfinApi - /// -> AddJsonOptions. - /// </remarks> - /// <returns>The default <see cref="JsonSerializerOptions" /> options.</returns> - public static JsonSerializerOptions GetOptions() - { - var options = new JsonSerializerOptions - { - ReadCommentHandling = JsonCommentHandling.Disallow, - WriteIndented = false, - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - NumberHandling = JsonNumberHandling.AllowReadingFromString - }; - - options.Converters.Add(new JsonGuidConverter()); - options.Converters.Add(new JsonStringEnumConverter()); - - return options; - } - - /// <summary> - /// Gets camelCase json options. - /// </summary> - /// <returns>The camelCase <see cref="JsonSerializerOptions" /> options.</returns> - public static JsonSerializerOptions GetCamelCaseOptions() - { - var options = GetOptions(); - options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; - return options; - } - - /// <summary> - /// Gets PascalCase json options. - /// </summary> - /// <returns>The PascalCase <see cref="JsonSerializerOptions" /> options.</returns> - public static JsonSerializerOptions GetPascalCaseOptions() - { - var options = GetOptions(); - options.PropertyNamingPolicy = null; - return options; - } - } -} |
