Ignore POCO's null by default


#1

Hi,

Is there a way to add a property to a POCO (the class, not the members) that instructs CB to ignore all null values instead of manually adding to each member ?

According to the documentation one can use this on a class when serializing but I’m looking for a class attribute :
string ignored = JsonConvert.SerializeObject(movie, Formatting.Indented,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });

Thanks,


#2

@itay -

This is more of a question for NewtonSoft, but this SO post seems to indicate that it’s possible via JsonProperty(NullValueHandling=NullValueHandling.Ignore).

-Jeff


#3

Hi Jeff,
This is also in the link I sent yet it marks a specific class member to ignore nulls, not the entire class.
I have many class members and adding this attribute to each of them makes the code harder to read and manage so I’m looking for one attribute to rule them all