I also turn off PropertyNameCaselnsensitive unless I have a strong reason not to.
Rule I follow now:
Be strict at service boundaries. Be explicit in your models.
Loose deserialization doesn't make systems resilient.
It makes bugs harder to see.
I lost half a day debugging a null bug that wasn't a bug at all.
It was bad JSON deserialization.
By default, System. Text.Json is very forgiving. Extra fields? Ignored. Missing fields?
Defaulted. No errors. Just broken state.
Two things changed how I handle this:
UnmappedMemberHandling = Disallow to catch unexpected fields when an API contract drifts.
Required members via required properties or [JsonRequired] so missing data fails fast instead of leaking nulls.
I lost half a day debugging a null bug that wasn't a bug at all.
It was bad JSON deserialization.
By default, System. Text.Json is very forgiving. Extra fields? Ignored. Missing fields?
Defaulted. No errors. Just broken state.