I'm trying to serialize a large struct with loads of enums, and when a property in the struct is not set, I would like to get the first enum string value to be serialized in json instead im getting 0 as a default value.
public enum YesNoUnknown
{
[EnumName(Name = "unknown")]
Unknown,
[EnumName(Name = "yes")]
Yes,
[EnumName(Name = "no")]
No
}
[JsonProperty(PropertyName = "property1", ItemConverterType = typeof(EnumAttributeConverter<YesNoUnknown>))]
public YesNoUnknown Property1 { get; set; }
I want the default result to be: property1: "unknown" instead of: property1: 0
Thanks in advance!