Consider a bool value "IsReady
"
I can set this as nullable and ignore this during serialization by NullValueHandling = NullValueHandling.Ignore
or I can set the DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore
The problem here is if I need to change the the property to nullable then there are hundreds of property I need to do. Given the situation I don't think I will be allowed to do this as this will also require code change in other modules too.
The problem with second approach is the in real time there are instances where IsReady
will be false
and I want it to be serialized.
So I am not sure what could be the best approach here.
I would like to know if there any way to avoid serializing a property if it is null or was not set explicitly in the code.
I am using json.net