I need to serialize an enum's values to a string other than the name.
I tried doing this (see code below) but the attribute [EnumMember(Value = "name")]
didn't change anything. When I do .ToJson()
I can see that the value is still "Monday" and not "MONDAY"
[DataContract]
public enum Day
{
[EnumMember(Value = "MONDAY")]
Monday,
[EnumMember(Value = "TUESDAY")]
Tuesday,
[EnumMember(Value = "WEDNESDAY")]
Wednesday,
[EnumMember(Value = "THURSDAY")]
Thursday,
[EnumMember(Value = "FRIDAY")]
Friday,
[EnumMember(Value = "SATURDAY")]
Saturday,
[EnumMember(Value = "SUNDAY")]
Sunday,
}