This sample uses a Argon.SnakeCaseNamingStrategy
specified using a contract resolver to snake case serialized property names.
public class User
{
public string UserName { get; set; }
public bool Enabled { get; set; }
}
var user1 = new User
{
UserName = "jamesn",
Enabled = true
};
var contractResolver = new DefaultContractResolver
{
NamingStrategy = new SnakeCaseNamingStrategy()
};
var json = JsonConvert.SerializeObject(user1, new JsonSerializerSettings
{
ContractResolver = contractResolver,
Formatting = Formatting.Indented
});
Console.WriteLine(json);
// {
// "user_name": "jamesn",
// "enabled": true
// }