How could i deserialize json into a List of enum in C#?
I wrote the following code:
//json "types" : [ "hotel", "spa" ] public enum eType { [Description("hotel")] kHotel, [Description("spa")] kSpa } public class HType { List<eType> m_types; [JsonProperty("types")] public List<eType> HTypes { get { return m_types; } set { // i did this to try and decide in the setter // what enum value should be for each type // making use of the Description attribute // but throws an exception } } }
//other class var hTypes = JsonConvert.DeserializeObject<HType>(json);