diff options
| author | Vasily <JustAMan@users.noreply.github.com> | 2019-10-10 18:15:48 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-10 18:15:48 +0300 |
| commit | 79f9887625bdc5ae5afead89387603023a34570e (patch) | |
| tree | 8f4b0dcd1cbd02e68abed444cedea967b7b7133b /MediaBrowser.Common/Json/JsonDefaults.cs | |
| parent | c6cb4b7cf86c68ce64a5c4f128caa6d645eb0a9c (diff) | |
| parent | e553eba31e9f0e05effc30417ee53c02d63304bd (diff) | |
Merge pull request #1854 from Bond-009/json
Use System.Text.Json api for databases
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; + } + } +} |
