We are serialising an object to JSON which has a property that is an array of dynamic objects, e.g.:
public List<dynamic> Widgets { get; set; }
public string Name {get;set;}
The serialisation is set to use the built in camel case resolver, with the option ProcessDictionaryKeys set to true, as per advice from this post :
var contractResolver = new CamelCasePropertyNamesContractResolver();
contractResolver.NamingStrategy.ProcessDictionaryKeys = true;
jsonSerializerSettings.ContractResolver = contractResolver;
However the resultant JSON retains the pascal case (which is how the objects are stored in the database) for the entries in this field. All other properties get converted to camel case as expected.
Example output for the above:
{
name:"test",
widgets:[{Name:"Widget1",Description:"A nice widget"}]
}
So why does the naming strategy only apply to strongly typed C# objects and not these dynamic values?
I have verified the obvious things, i.e. ensured the serialisation settings are being applied.