Do not treat ignored field as missing member when deserializing from overriden json constructor (#2224)
This commit is contained in:
committed by
James Newton-King
parent
7c3d7f8da7
commit
9be95e0f6a
@@ -2201,30 +2201,33 @@ namespace Newtonsoft.Json.Serialization
|
||||
propertyValues.Add(creatorPropertyContext);
|
||||
|
||||
JsonProperty? property = creatorPropertyContext.ConstructorProperty ?? creatorPropertyContext.Property;
|
||||
if (property != null && !property.Ignored)
|
||||
if (property != null)
|
||||
{
|
||||
if (property.PropertyContract == null)
|
||||
if (!property.Ignored)
|
||||
{
|
||||
property.PropertyContract = GetContractSafe(property.PropertyType);
|
||||
}
|
||||
if (property.PropertyContract == null)
|
||||
{
|
||||
property.PropertyContract = GetContractSafe(property.PropertyType);
|
||||
}
|
||||
|
||||
JsonConverter? propertyConverter = GetConverter(property.PropertyContract, property.Converter, contract, containerProperty);
|
||||
JsonConverter? propertyConverter = GetConverter(property.PropertyContract, property.Converter, contract, containerProperty);
|
||||
|
||||
if (!reader.ReadForType(property.PropertyContract, propertyConverter != null))
|
||||
{
|
||||
throw JsonSerializationException.Create(reader, "Unexpected end when setting {0}'s value.".FormatWith(CultureInfo.InvariantCulture, memberName));
|
||||
}
|
||||
if (!reader.ReadForType(property.PropertyContract, propertyConverter != null))
|
||||
{
|
||||
throw JsonSerializationException.Create(reader, "Unexpected end when setting {0}'s value.".FormatWith(CultureInfo.InvariantCulture, memberName));
|
||||
}
|
||||
|
||||
if (propertyConverter != null && propertyConverter.CanRead)
|
||||
{
|
||||
creatorPropertyContext.Value = DeserializeConvertable(propertyConverter, reader, property.PropertyType!, null);
|
||||
if (propertyConverter != null && propertyConverter.CanRead)
|
||||
{
|
||||
creatorPropertyContext.Value = DeserializeConvertable(propertyConverter, reader, property.PropertyType!, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
creatorPropertyContext.Value = CreateValueInternal(reader, property.PropertyType, property.PropertyContract, property, contract, containerProperty, null);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
creatorPropertyContext.Value = CreateValueInternal(reader, property.PropertyType, property.PropertyContract, property, contract, containerProperty, null);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user