DefaultContractResolver .net exclude null values JsonSerializerSettings ContractResolver DefaultContractResolver

40

DefaultContractResolver .net exclude null values JsonSerializerSettings ContractResolver DefaultContractResolver -

public class DataContractResolver : DefaultContractResolver
{
    protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
    {
        var property = base.CreateProperty(member, memberSerialization);
        property.NullValueHandling = NullValueHandling.Include;
        property.DefaultValueHandling = DefaultValueHandling.Include;
        property.ShouldSerialize = o => true;
        return property;
    }
}

Comments

Submit
0 Comments