I have a class that contains an enum
property, and upon serializing the object using JavaScriptSerializer
, my json result contains the integer valu
This is easily done by adding a ScriptIgnore attribute to the Gender
property, causing it to not be serialised, and adding a GenderString
property which does get serialised:
class Person
{
int Age { get; set; }
[ScriptIgnore]
Gender Gender { get; set; }
string GenderString { get { return Gender.ToString(); } }
}