Closed ahmetkoprulu closed 3 weeks ago
Implement a custom contract resolver deriving from DefaultContractResolver. Override its CreateProperty
method in such a way that it:
This basically sets the json property names to the names of the respective .NET instance field/property names, effectively undoing any custom json property name taken from [JsonProperty]. (Additionally, if necessary, make this dependent on the value of the JsonProperty.DeclaringType
property to limit this behavior only to properties/fields in desired types.)
Then assign this custom contract resolver to the ContractResolver
property of the JsonSerializerSettings used for (de)serialization, and Bob should be your uncle...
Thanks for the answer. It seems like that would work. I am closing the issue.
Source/destination types
Source/destination JSON
Expected behavior
I want to ignore the JsonProperty attribute manually by passing serializer settings or something else. Is it possible to achieve this behavior? I could not find any resource about it.