Click or drag to resize
Json.NET

Camel case property names

 

This sample uses a CamelCaseNamingStrategy specified using a contract resolver to camel case serialized property names.

Sample
Types
public class User
{
    public string UserName { get; set; }
    public bool Enabled { get; set; }
}
Usage
User user1 = new User
{
    UserName = "jamesn",
    Enabled = true
};

DefaultContractResolver contractResolver = new DefaultContractResolver
{
    NamingStrategy = new CamelCaseNamingStrategy()
};

string json = JsonConvert.SerializeObject(user1, new JsonSerializerSettings
{
    ContractResolver = contractResolver,
    Formatting = Formatting.Indented
});

Console.WriteLine(json);
// {
//   "userName": "jamesn",
//   "enabled": true
// }