When using JSON.Net in ASP.Net Core 2.2 I was able to ignore a property when its value was null when serializing to JSON:
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public DateTime? Created { get; set; }
But when using the new ASP.Net Core 3.0 built in JSON (System.Text.Json) I can’t find an equivalent attribute to ignore a property if its value is null.
I could only find JsonIgnore.
Am I missing something?
This was fixed on .Net 5
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
See the updates below