update JsonConverters for unstable support

This commit is contained in:
Cody Robibero 2024-02-20 17:52:01 -07:00
parent 3820ea7203
commit 8630385c12
2 changed files with 5 additions and 5 deletions

View File

@ -10,10 +10,10 @@ namespace Jellyfin.Sdk.JsonConverters;
public class JsonGuidConverter : JsonConverter<Guid>
{
/// <inheritdoc />
public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
public override Guid Read(ref Utf8JsonReader reader, System.Type typeToConvert, JsonSerializerOptions options)
{
var guidStr = reader.GetString();
return guidStr == null ? Guid.Empty : new Guid(guidStr);
return string.IsNullOrEmpty(guidStr) ? Guid.Empty : new Guid(guidStr);
}
/// <inheritdoc />

View File

@ -11,16 +11,16 @@ namespace Jellyfin.Sdk.JsonConverters;
public class JsonNullableGuidConverter : JsonConverter<Guid?>
{
/// <inheritdoc />
public override Guid? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
public override Guid? Read(ref Utf8JsonReader reader, System.Type typeToConvert, JsonSerializerOptions options)
{
var guidStr = reader.GetString();
return guidStr == null ? null : (Guid?)new Guid(guidStr);
return string.IsNullOrEmpty(guidStr) ? null : new Guid(guidStr);
}
/// <inheritdoc />
public override void Write(Utf8JsonWriter writer, Guid? value, JsonSerializerOptions options)
{
if (value == null || value == Guid.Empty)
if (value is null || value.Value.Equals(default))
{
writer.WriteNullValue();
}