diff options
| author | Bond-009 <bond.009@outlook.com> | 2020-04-25 11:09:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-25 11:09:38 +0200 |
| commit | 383bc453728684bca187e826ff099493175ba312 (patch) | |
| tree | a6da02b3978e1ef13d6aeb04b56d9dc64e1195de /Jellyfin.Server/Models/JsonOptions.cs | |
| parent | a2f19eadf739297cbbc99c9082b0175e8b881054 (diff) | |
| parent | 0765ef8bda4d23e33fde7a1bfe49b5a365c6d28e (diff) | |
Merge pull request #2932 from crobibero/api-casing
Add optional camelCase formatter
Diffstat (limited to 'Jellyfin.Server/Models/JsonOptions.cs')
| -rw-r--r-- | Jellyfin.Server/Models/JsonOptions.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Jellyfin.Server/Models/JsonOptions.cs b/Jellyfin.Server/Models/JsonOptions.cs new file mode 100644 index 000000000..2f0df3d2c --- /dev/null +++ b/Jellyfin.Server/Models/JsonOptions.cs @@ -0,0 +1,41 @@ +using System.Text.Json; + +namespace Jellyfin.Server.Models +{ + /// <summary> + /// Json Options. + /// </summary> + public static class JsonOptions + { + /// <summary> + /// Gets CamelCase json options. + /// </summary> + public static JsonSerializerOptions CamelCase + { + get + { + var options = DefaultJsonOptions; + options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + return options; + } + } + + /// <summary> + /// Gets PascalCase json options. + /// </summary> + public static JsonSerializerOptions PascalCase + { + get + { + var options = DefaultJsonOptions; + options.PropertyNamingPolicy = null; + return options; + } + } + + /// <summary> + /// Gets base Json Serializer Options. + /// </summary> + private static JsonSerializerOptions DefaultJsonOptions => new JsonSerializerOptions(); + } +} |
