using Newtonsoft.Json.Serialization;
public static void Main()
var myClass = new MyClass
AnotherName = "pineapple",
AnotherValue = "not as delicious as the apple"
var settings = new JsonSerializerSettings
ContractResolver = new CustomResolver(),
Formatting = Formatting.Indented
var json = JsonConvert.SerializeObject(myClass, settings);
[JsonLocaleProperty("name")]
public string SomeName { get; set; }
[JsonLocaleProperty("specialTypeId")]
public int SpecialTypeId { get; set; }
public string AnotherName { get; set; }
public string AnotherValue { get; set; }
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class JsonLocalePropertyAttribute : Attribute
public string PropertyName { get; set; }
public JsonLocalePropertyAttribute(string propertyName)
PropertyName = propertyName;
public class CustomResolver : CamelCasePropertyNamesContractResolver
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
JsonProperty property = base.CreateProperty(member, memberSerialization);
JsonLocalePropertyAttribute customAttribute = (JsonLocalePropertyAttribute)property.AttributeProvider.GetAttributes(typeof(JsonLocalePropertyAttribute), true).FirstOrDefault();
if (customAttribute != null)
if(customAttribute.PropertyName == "specialTypeId")
property.PropertyName = "otherDutyTypeId";
property.PropertyName = customAttribute.PropertyName;