aboutsummaryrefslogtreecommitdiff
path: root/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2021-12-24 02:01:06 +0000
committerGitHub <noreply@github.com>2021-12-24 02:01:06 +0000
commitcecfdeeec3effa61de2a83b5656059c08536d94e (patch)
treeb77ae70228a2f62d12b258e9467721bdc4bf44fc /src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs
parentfcf5b9b46e7d120904fdafb3df726b1a1309660d (diff)
parent076a13abeb344f7a79d81cce030799c8e77dbfaf (diff)
Merge branch 'master' into unharden-for-lxc
Diffstat (limited to 'src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs')
-rw-r--r--src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs b/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs
index 6192d1598..b477bcb66 100644
--- a/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs
+++ b/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs
@@ -1,5 +1,4 @@
using System;
-using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -12,21 +11,19 @@ namespace Jellyfin.Extensions.Json.Converters
{
/// <inheritdoc />
public override Guid? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- var guidStr = reader.GetString();
- return guidStr == null ? null : new Guid(guidStr);
- }
+ => JsonGuidConverter.ReadInternal(ref reader);
/// <inheritdoc />
public override void Write(Utf8JsonWriter writer, Guid? value, JsonSerializerOptions options)
{
- if (value == null || value == Guid.Empty)
+ if (value == Guid.Empty)
{
writer.WriteNullValue();
}
else
{
- writer.WriteStringValue(value.Value.ToString("N", CultureInfo.InvariantCulture));
+ // null got handled higher up the call stack
+ JsonGuidConverter.WriteInternal(writer, value!.Value);
}
}
}