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.
The problem with only using the properties inside of them.
OptionalJsonConverter
is that it can't choose when a property is serialized unless you convert full objects which have OptionalHowever, the problem with serializing full objects is then you need to take care of ensuring that the
JsonPropertyAttribute
andJsonIgnoreAttribute
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.