mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-05-04 18:50:23 +02:00
Fixed: Handle null IEnumerable field values in SchemaBuilder
This commit is contained in:
parent
6c35c3fc6f
commit
011fd57f7d
1 changed files with 11 additions and 3 deletions
|
|
@ -226,7 +226,11 @@ private static Func<object, object> GetValueConverter(Type propertyType)
|
|||
{
|
||||
return fieldValue =>
|
||||
{
|
||||
if (fieldValue is JsonElement e && e.ValueKind == JsonValueKind.Array)
|
||||
if (fieldValue == null)
|
||||
{
|
||||
return Enumerable.Empty<int>();
|
||||
}
|
||||
else if (fieldValue is JsonElement e && e.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
return e.EnumerateArray().Select(s => s.GetInt32());
|
||||
}
|
||||
|
|
@ -240,13 +244,17 @@ private static Func<object, object> GetValueConverter(Type propertyType)
|
|||
{
|
||||
return fieldValue =>
|
||||
{
|
||||
if (fieldValue is JsonElement e && e.ValueKind == JsonValueKind.Array)
|
||||
if (fieldValue == null)
|
||||
{
|
||||
return Enumerable.Empty<string>();
|
||||
}
|
||||
else if (fieldValue is JsonElement e && e.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
return e.EnumerateArray().Select(s => s.GetString());
|
||||
}
|
||||
else
|
||||
{
|
||||
return fieldValue.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim());
|
||||
return fieldValue.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => v.Trim());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue