I'm rewriting an api, switching from newtonsoft.json to system.text.json, and an issue i have is the fact that in some cases we send enums as ints and sometimes as strings.
Consider this example:
{
"result":
{
"RequestTypeEnum":"Request.Get"
},
"resultTypeEnum": 0
}
How can I achieve this in system.text.json ? I know that for pascal/camel case Json Naming Properties can be used, but I'm unaware how to handle enums differently in the same response
It may not be complete answer.
Integer to Enum conversion automatically happen.
For string to Enum you have to write your own convertor.
Following is the sample I tried.