harvzor / harvzor-optional

A type wrapper that lets you know if that object value has been explicitly defined
MIT License
0 stars 0 forks source link

Newtonsoft with contract resolver #1

Closed harvzor closed 1 year ago

harvzor commented 1 year ago

The problem with only using the OptionalJsonConverter is that it can't choose when a property is serialized unless you convert full objects which have Optional properties inside of them.

However, the problem with serializing full objects is then you need to take care of ensuring that the JsonPropertyAttribute and JsonIgnoreAttribute still work, as well as many other edge cases (such as how indentation should work).

A contract resolver lets you choose which properties are even attempted to be serialized.