I am trying to deserialize my API request body to object.
My json looks like this:
{
"EmployeeId": 123,
"EmployeeName": "Tony",
"EmployeeType": "Contractor"
}
My Class looks like:
public class RequestDto
{
public int EmployeeId {get; set;}
public string EmployeeName {get; set;}
public EmployeeType {get; set;}
}
My EmployeeType Enum
public enum EmployeeType
{
Uknown,
FullTime,
Vendor
}
I am using .net core 3.1 and i have added newtonsoft converters stringEnumConverter() in my startup.cs as well. with the above json, im getting an error converting the value to enum. I want it to be converted to default enum value when there is an unknown string value which is not available in the enum class. Is there any way .net core/newtonsoft allows me to do it without adding any custom converters which inherits from StringEnumConverter().