5

We have used property-level NullValueHandling to ignore null-values when serializing object:

[Newtonsoft.Json.JsonProperty("Topic", NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string Topic { get; set; }

Now it turns out that in one scenario we should serialize every property, even if they have NullValueHandling.Ignore and the property value is null.

Is it possible to override the property-level NullValueHandling-rules when serializing objects with Json.NET?

Mikael Koskinen
  • 12,306
  • 5
  • 48
  • 63
  • I think the contract resolver from [JSON.net not including null properties with EmitDefaultValue false](https://stackoverflow.com/a/38961409) should work. Agree? – dbc Oct 04 '18 at 11:00

0 Answers0