mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-20 21:54:25 -04:00
New: Use System.Text.Json for Nancy and SignalR
This commit is contained in:
@@ -2,10 +2,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Text.Json;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Reflection;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Annotations;
|
||||
|
||||
namespace Readarr.Http.ClientSchema
|
||||
@@ -213,9 +214,9 @@ namespace Readarr.Http.ClientSchema
|
||||
{
|
||||
return Enumerable.Empty<int>();
|
||||
}
|
||||
else if (fieldValue.GetType() == typeof(JArray))
|
||||
else if (fieldValue is JsonElement e && e.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
return ((JArray)fieldValue).Select(s => s.Value<int>());
|
||||
return e.EnumerateArray().Select(s => s.GetInt32());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -231,9 +232,9 @@ namespace Readarr.Http.ClientSchema
|
||||
{
|
||||
return Enumerable.Empty<string>();
|
||||
}
|
||||
else if (fieldValue.GetType() == typeof(JArray))
|
||||
else if (fieldValue is JsonElement e && e.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
return ((JArray)fieldValue).Select(s => s.Value<string>());
|
||||
return e.EnumerateArray().Select(s => s.GetString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -243,7 +244,18 @@ namespace Readarr.Http.ClientSchema
|
||||
}
|
||||
else
|
||||
{
|
||||
return fieldValue => fieldValue;
|
||||
return fieldValue =>
|
||||
{
|
||||
var element = fieldValue as JsonElement?;
|
||||
|
||||
if (element == null || !element.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var json = element.Value.GetRawText();
|
||||
return STJson.Deserialize(json, propertyType);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user