0

its my enum

public enum Employee_roles
{
    admin,
    controller,
    planner,
    stockkeeper,
    client,
    bpengineer,
    superintendent,
    seniorengineer,
    procurementmanager,
    hseadmin,
    hseclient,
    rawadmin,
}

this model class

public class access_right
{

    public string id { get; set; }
    public string model { get; set; }
    [JsonConverter(typeof(StringEnumConverter))]
    public method method { get; set; }
    [JsonConverter(typeof(StringEnumConverter))]
    public List<Employee_roles> roles { get; set; }
    public List<string> email { get; set; }
    [JsonConverter(typeof(StringEnumConverter))]
    public access_type access { get; set; }

}

**roles property is List. if it's not list no problem [JsonConverter(typeof(StringEnumConverter))] this method working. But List how to convert please help me **

1
  • You can get enums string values using [Flags] attribute Commented Dec 5, 2017 at 12:02

2 Answers 2

0
var list = Enum.GetNames(typeof(Employee_roles)).ToList();
Sign up to request clarification or add additional context in comments.

Comments

0

If you want to save for example your roles as strings, you can use the JsonPropertyAttribute.ItemConverterType property like so:

[JsonProperty (ItemConverterType = typeof(StringEnumConverter))]
public List<Employee_roles> roles { get; set; }

1 Comment

thanks very helpful thank you sir

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.