I can use the ExcludeDefaultValues
to exclude json serializing of null
values in strings. But I also want ""
to be excluded. I do not have access to the model to set custom attributes. Is there a way to create a kind of override in the string serializer?
In Newtonsoft I can do:
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
{
var property = base.CreateProperty(member, memberSerialization);
if (property.PropertyType == typeof(string))
{
property.DefaultValue = "";
}
return property;
}
but I want to use SS if possible.
Thanks.