0

There is a question about generically converting enums to/from strings. This questions is a little different.

Is there a way in an ASP.NET Web API 2 app to define the controller API for a call where it will receive/return JSON where the property is a string in the JSON, but it is declared as an enum?

1

1 Answer 1

1

If you are using JSON.NET, you can use the following attribute for your Enum object-

[JsonConverter(typeof(StringEnumConverter))]

Check this link.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.