This sample configures a Argon.CamelCaseNamingStrategy
to not camel case properties that already have a name specified with an attribute.
public class User
{
public string FirstName { get; set; }
public string LastName { get; set; }
[JsonProperty(PropertyName = "UPN")] public string Upn { get; set; }
}
var user = new User
{
FirstName = "John",
LastName = "Smith",
Upn = "[email protected]"
};
var contractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy
{
OverrideSpecifiedNames = false
}
};
var json = JsonConvert.SerializeObject(user, new JsonSerializerSettings
{
ContractResolver = contractResolver,
Formatting = Formatting.Indented
});
Console.WriteLine(json);
// {
// "firstName": "John",
// "lastName": "Smith",
// "UPN": "[email protected]"
// }