-Changed DataContractAttribute on collections back to array serialization
-Fixed JObject.GetPropertyOwner to return value -Fixed JPropertyDescriptor GetValue and SetValue to return null for null owner
This commit is contained in:
@@ -780,6 +780,11 @@ namespace Newtonsoft.Json.Linq
|
||||
|
||||
object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
|
||||
{
|
||||
if (pd is JPropertyDescriptor)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -69,9 +69,7 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <param name="component">The component with the property for which to retrieve the value.</param>
|
||||
public override object GetValue(object component)
|
||||
{
|
||||
JToken token = CastInstance(component)[Name];
|
||||
|
||||
return token;
|
||||
return (component as JObject)?[Name];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -89,9 +87,12 @@ namespace Newtonsoft.Json.Linq
|
||||
/// <param name="value">The new value.</param>
|
||||
public override void SetValue(object component, object value)
|
||||
{
|
||||
JToken token = value as JToken ?? new JValue(value);
|
||||
if (component is JObject o)
|
||||
{
|
||||
JToken token = value as JToken ?? new JValue(value);
|
||||
|
||||
CastInstance(component)[Name] = token;
|
||||
o[Name] = token;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1176,15 +1176,6 @@ namespace Newtonsoft.Json.Serialization
|
||||
return CreateDictionaryContract(objectType);
|
||||
}
|
||||
|
||||
#if HAVE_DATA_CONTRACTS
|
||||
// don't use GetDataContractAttribute because it looks for the attribute on base classes
|
||||
DataContractAttribute dataContractAttribute = JsonTypeReflector.GetCachedAttribute<DataContractAttribute>(objectType);
|
||||
if (dataContractAttribute != null)
|
||||
{
|
||||
return CreateObjectContract(objectType);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (t == typeof(JToken) || t.IsSubclassOf(typeof(JToken)))
|
||||
{
|
||||
return CreateLinqContract(objectType);
|
||||
|
||||
Reference in New Issue
Block a user