A class that contains an enum property and serializing the object using JavaScriptSerializer. When i serialize the JSON i am getting index value rather the text. As an example:
public enum LocationType
{
[Description("Description 1") ,EnumMember(Value = "EST")]
EST = 1,
[Description("Description 2"), EnumMember(Value = "INTNS")]
INTNS = 2,
[Description("Description 3"), EnumMember(Value = "INTS")]
INTS = 3
}
public class Details
{
public LocationType? LocationType { get; set; }
}
List<Details> obj = new List<Details>();
obj.Add(new Details() { LocationType = LocationType.INTNS });
obj.Add(new Details() { LocationType = LocationType.INTS });
obj.Add(new Details() { LocationType = LocationType.EST });
obj.Add(new Details() { LocationType = LocationType.INTS });
obj.Add(new Details() { LocationType = LocationType.EST });
obj.Add(new Details() { LocationType = LocationType.EST });
obj.Add(new Details() { LocationType = LocationType.INTS });
obj.Add(new Details() { LocationType = LocationType.EST });
return obj;
Actual json result:
{ "LocationType ": 2 }
Expected json result:
{ "LocationType ": "INTNS" }