I want my class to be serialized and deserialized using camel case naming convention. I know I can use the JsonConvert.SerializeObject(object, settings)
overload as stated here:
var serializerSettings = new JsonSerializerSettings();
serializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
var json = JsonConvert.SerializeObject(product, serializerSettings);
Is there any way to apply the same configuration on a class level (via attributes) so that I do not need to override the serialization settings?
I could write a custom converter but that looks like an overkill for such a simple thing.
See Question&Answers more detail:os