-Fixed deserializing null value onto JObject or JArray proeprty

This commit is contained in:
James Newton-King
2014-11-01 10:10:29 +13:00
parent 70d3e9327d
commit 55e482c930
6 changed files with 101 additions and 6 deletions
@@ -268,7 +268,15 @@ namespace Newtonsoft.Json.Serialization
private object CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue)
{
if (contract != null && contract.ContractType == JsonContractType.Linq)
return CreateJToken(reader, contract);
{
JToken token = CreateJToken(reader, contract);
// test to make sure token is valid when null, e.g. can't set JValue.Null to JObject proeprty
if (token.Type == JTokenType.Null && !contract.UnderlyingType.IsAssignableFrom(typeof(JValue)))
return null;
return token;
}
do
{