I have this enum
public enum OrchestrationRuntimeStatus
{
Unknown = -1,
Running = 0,
Completed = 1,
ContinuedAsNew = 2,
Failed = 3,
Canceled = 4,
Terminated = 5,
Pending = 6
}
There is a variable in my class status of the type OrchestrationRuntimeStatus. The variable is
public sealed class status
{
[JsonConverter(typeof(StringEnumConverter))]
public OrchestrationRuntimeStatus RuntimeStatus { get; set; }
}
I have another function whose return type is OkObjectResultWithHeaders(status, headers).
When I see the value of status.RuntimeStatus in the above function it is showing as unknown, running, I want to show it as -1, 0. Is there a way serialize or de-serialize to show those strings as integers?
PS: Feel free to edit the question as I didn't write it correctly.
CodePudding user response:
[JsonConverter(typeof(StringEnumConverter))]
preforms the serialisation of the enum to string. Simply removing this will default the serialisation to an int.