Click or drag to resize
Json.NET

JsonObjectAttribute NamingStrategy setting

 

This sample uses NamingStrategy types specified on attributes to control serialized property names.

Sample
Types
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class User
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    [JsonProperty(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
    public int SnakeRating { get; set; }
}
Usage
User user = new User
{
    FirstName = "Tom",
    LastName = "Riddle",
    SnakeRating = 10
};

string json = JsonConvert.SerializeObject(user, Formatting.Indented);

Console.WriteLine(json);
// {
//   "firstName": "Tom",
//   "lastName": "Riddle",
//   "snake_rating": 10
// }