mirror of
https://github.com/jellyfin/jellyfin-sdk-csharp.git
synced 2024-11-26 23:20:43 +00:00
update JsonConverters for unstable support
This commit is contained in:
parent
3820ea7203
commit
8630385c12
@ -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 />
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user