aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs')
-rw-r--r--MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs13
1 files changed, 10 insertions, 3 deletions
diff --git a/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs b/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs
index c408a3be1..c83657b5f 100644
--- a/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs
@@ -24,10 +24,16 @@ namespace MediaBrowser.Common.Json.Converters
/// <inheritdoc />
public override T[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
+ if (reader.TokenType == JsonTokenType.Null)
+ {
+ return Array.Empty<T>();
+ }
+
if (reader.TokenType == JsonTokenType.String)
{
- var stringEntries = reader.GetString()?.Split('|', StringSplitOptions.RemoveEmptyEntries);
- if (stringEntries == null || stringEntries.Length == 0)
+ // GetString can't return null here because we already handled it above
+ var stringEntries = reader.GetString()!.Split('|', StringSplitOptions.RemoveEmptyEntries);
+ if (stringEntries.Length == 0)
{
return Array.Empty<T>();
}
@@ -63,7 +69,8 @@ namespace MediaBrowser.Common.Json.Converters
return typedValues;
}
- return JsonSerializer.Deserialize<T[]>(ref reader, options);
+ // can't return null here because we already handled it above
+ return JsonSerializer.Deserialize<T[]>(ref reader, options)!;
}
/// <inheritdoc />