Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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;
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #DefaultContractResolver #exclude #null #values #JsonSerializerSettings #ContractResolver #DefaultContractResolver
ADD COMMENT
Topic
Name
4+4 =