diff options
| author | Bond_009 <bond.009@outlook.com> | 2019-09-25 17:43:20 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2019-10-08 20:59:53 +0200 |
| commit | e553eba31e9f0e05effc30417ee53c02d63304bd (patch) | |
| tree | 7d96ff17db0b3e520bd5a8b9c14784429910fcdf /MediaBrowser.Common/Json/JsonDefaults.cs | |
| parent | ac9dfa8e93106d907bbf78fe2350adfa47c76cec (diff) | |
Use System.Text.Json api
Diffstat (limited to 'MediaBrowser.Common/Json/JsonDefaults.cs')
| -rw-r--r-- | MediaBrowser.Common/Json/JsonDefaults.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Json/JsonDefaults.cs b/MediaBrowser.Common/Json/JsonDefaults.cs new file mode 100644 index 000000000..4ba0d5a1a --- /dev/null +++ b/MediaBrowser.Common/Json/JsonDefaults.cs @@ -0,0 +1,30 @@ +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> + /// <returns>The default <see cref="JsonSerializerOptions" /> options.</returns> + public static JsonSerializerOptions GetOptions() + { + var options = new JsonSerializerOptions() + { + ReadCommentHandling = JsonCommentHandling.Disallow, + WriteIndented = false + }; + + options.Converters.Add(new GuidConverter()); + options.Converters.Add(new JsonStringEnumConverter()); + + return options; + } + } +} |
