diff options
| author | crobibero <cody@robibe.ro> | 2020-05-21 08:44:15 -0600 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2020-06-02 08:23:12 -0600 |
| commit | 4fe0beec162d4554f1d6cc3c658b672eafbfa307 (patch) | |
| tree | 25ea221e7927895489d7d8381e45fb29eadcd6db /MediaBrowser.Common/Json/JsonDefaults.cs | |
| parent | 297ab2e423235fd53f8e9e06dc4c15ee789278d3 (diff) | |
Fix Json Enum conversion, map all JsonDefaults properties to API
Diffstat (limited to 'MediaBrowser.Common/Json/JsonDefaults.cs')
| -rw-r--r-- | MediaBrowser.Common/Json/JsonDefaults.cs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/MediaBrowser.Common/Json/JsonDefaults.cs b/MediaBrowser.Common/Json/JsonDefaults.cs index 4a6ee0a79..326f04eea 100644 --- a/MediaBrowser.Common/Json/JsonDefaults.cs +++ b/MediaBrowser.Common/Json/JsonDefaults.cs @@ -12,10 +12,16 @@ namespace MediaBrowser.Common.Json /// <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() + var options = new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Disallow, WriteIndented = false @@ -26,5 +32,31 @@ namespace MediaBrowser.Common.Json return options; } + + /// <summary> + /// Gets CamelCase json options. + /// </summary> + public static JsonSerializerOptions CamelCase + { + get + { + var options = GetOptions(); + options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + return options; + } + } + + /// <summary> + /// Gets PascalCase json options. + /// </summary> + public static JsonSerializerOptions PascalCase + { + get + { + var options = GetOptions(); + options.PropertyNamingPolicy = null; + return options; + } + } } } |
