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/Converters/GuidConverter.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/Converters/GuidConverter.cs')
| -rw-r--r-- | MediaBrowser.Common/Json/Converters/GuidConverter.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Json/Converters/GuidConverter.cs b/MediaBrowser.Common/Json/Converters/GuidConverter.cs new file mode 100644 index 000000000..3081e12ee --- /dev/null +++ b/MediaBrowser.Common/Json/Converters/GuidConverter.cs @@ -0,0 +1,20 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace MediaBrowser.Common.Json.Converters +{ + /// <summary> + /// Converts a GUID object or value to/from JSON. + /// </summary> + public class GuidConverter : JsonConverter<Guid> + { + /// <inheritdoc /> + public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + => new Guid(reader.GetString()); + + /// <inheritdoc /> + public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options) + => writer.WriteStringValue(value); + } +} |
