Is there an attribute to prevent Jil from serializing properties that are null ?
In Newtonsoft it is :
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
Is there an attribute to prevent Jil from serializing properties that are null ?
In Newtonsoft it is :
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
Copyright © 2021 Jogjafile Inc.
For the whole object, the
excludeNulls
parameter onOptions
is what you want (many different Options configurations are pre-calced, anything likeOptions.ExcludeNulls
also works).You can control serialization of a single property with Conditional Serialization. (I forgot about this option in my original answer).
For example
Jil only respects the
Name
option on[DataMember]
. I suppose honoringEmitDefaultValue
wouldn't be the hardest thing, but nobody's ever opened an issue for it.