Ignore property when serializing under certain conditions
问题 Json.net has a very useful property that can be set on the JsonPropertyAttribute called NullValueHandling . If you decorate a property like this: [JsonProperty(NullValueHandling=NullValueHandling.Ignore)] string MyProp { get; set; } Then if MyProp is null, it won't be included in the output at all. I would like to do something similar, but with a different condition for exclusion. For example - say we have an enum public enum MyEnum { None = 0, Value1 = 1, Value2 = 2, Value3 = 4 }; And a