-Fix merging null with complex type and MergeNullValueHandling.Ignore

This commit is contained in:
James Newton-King
2016-12-08 09:47:01 +13:00
parent be8ca7a870
commit 4d425ccd06
2 changed files with 66 additions and 5 deletions
+1 -5
View File
@@ -190,17 +190,13 @@ namespace Newtonsoft.Json.Linq
else if (contentItem.Value != null)
{
JContainer existingContainer = existingProperty.Value as JContainer;
if (existingContainer == null)
if (existingContainer == null || existingContainer.Type != contentItem.Value.Type)
{
if (contentItem.Value.Type != JTokenType.Null || settings?.MergeNullValueHandling == MergeNullValueHandling.Merge)
{
existingProperty.Value = contentItem.Value;
}
}
else if (existingContainer.Type != contentItem.Value.Type)
{
existingProperty.Value = contentItem.Value;
}
else
{
existingContainer.Merge(contentItem.Value, settings);