Add decimal check in PolymorphicObjectConverter

In the PolymorphicObjectConverter class, the check for primitive types and specific object types was updated to include decimal.

Fixes #4714
This commit is contained in:
Sipke Schoorstra 2024-01-06 14:44:31 +01:00
parent 91ac5e816a
commit 70530aa9fe

View file

@ -158,7 +158,7 @@ public class PolymorphicObjectConverter : JsonConverter<object>
var newOptions = new JsonSerializerOptions(options);
var type = value.GetType();
if (type.IsPrimitive || value is string or DateTimeOffset or DateTime or DateOnly or TimeOnly or JsonElement or Guid or TimeSpan or Uri or Version or Enum)
if (type.IsPrimitive || value is string or decimal or DateTimeOffset or DateTime or DateOnly or TimeOnly or JsonElement or Guid or TimeSpan or Uri or Version or Enum)
{
// Remove the converter so that we don't end up in an infinite loop.
newOptions.Converters.RemoveWhere(x => x is PolymorphicObjectConverterFactory);