How to set camelCasing via attributing?

Jan 16, 2011 at 7:04 PM
Edited Jan 16, 2011 at 7:05 PM


Here's a typical object:

public class CaseDetail
   public string Message { get; set; }
   public bool Success { get; set; }
   public long Total { get; set; }
   public CaseItem Records { get; set; }

Is there a way to stipulate to use camelCase, via a class-level attribute, when the property names are converted into the JSON message?

Jan 19, 2011 at 12:22 PM

I would like to be able to set camel casing options at the class-level too; but I don't think it is possible at the moment.  I only know of one way to use camel casing and that is across the entire JsonSerializer instance (i.e. all objects will be serialized in camel case), by setting the JsonSerializer's ContractResolver to the CamelCasePropertyNamesContractResolver, which is provided as part of the library.