I want to camel case specific properties of an object using Json.NET rather than all of the properties.
I have an object like this:
class A {
public object B { get; set; }
public object C { get; set; } // this property should be camel cased
}
I want it to get serialized to this:
{ B: 1, c: 2 }
I came across this post about camel casing all properties unconditionally, which is done using:
var settings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
var json = JsonConvert.SerializeObject(a, settings);
But I couldn't find a counter-part question for camel casing a specific property. How is this done?