diff options
| author | Cody Robibero <cody@robibe.ro> | 2020-06-02 11:15:08 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-02 11:15:08 -0600 |
| commit | 93bca7ab50e47302fa2a214817088cf2841be3ed (patch) | |
| tree | 276416e33654aed4e3d5ca1d2688f96c20d916f7 /MediaBrowser.Common/Json/JsonDefaults.cs | |
| parent | 297ab2e423235fd53f8e9e06dc4c15ee789278d3 (diff) | |
| parent | 0e41c4727d84edbf4d7b96c59e0a3d3bec87b633 (diff) | |
Merge pull request #3153 from crobibero/api-json-enum
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; + } + } } } |
