1

Suppose a class Foo with 2 properties, PropertyA and PropertyB.

With JSON.NET i would like to use the DefaultContractResolver for serializing PropertyA and the CamelCasePropertyNamesContractResolver for serializing PropertyB.

So that the resultant serialized class would look like this.

Foo.PropertyA

Foo.propertyB

Is there a way to do this with JSON.NET?

Extra credit, i would prefer to denote which properties to serialize using the CamelCasePropertyNamesContractResolver by using an attibute.

  • You don't need to use a different contract resolver, you need to use a different [naming strategy](https://www.newtonsoft.com/json/help/html/NamingStrategySkipSpecifiedNames.htm). E.g. see [Newtonsoft JsonConvert.SerializeObject ignoring JsonProperty if name is uppercase](https://stackoverflow.com/a/48652197/3744182), [Configure Json.NET serialization settings on a class level](https://stackoverflow.com/q/44805490/3744182) or [How to apply a general rule for remapping all property names when serializing with Json.NET?](https://stackoverflow.com/a/46477576/3744182). – dbc Sep 19 '18 at 20:30
  • Do those linked questions also answer your question, or do you need additional help? If so can you please [edit] your question to share a [mcve] showing what your current classes with desired output JSON? – dbc Sep 19 '18 at 21:45

0 Answers0