Camel case property names |
This sample uses a CamelCaseNamingStrategy specified using a contract resolver to camel case serialized property names.
public class User { public string UserName { get; set; } public bool Enabled { get; set; } }
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 // }