How to set camelCasing via attributing?

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

Hi,

Here's a typical object:

[JsonObject(MemberSerialization.OptOut)]
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 1: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.