I am writing a test on a custom version of stringEnumConverter. But my test keeps throwing when I deserialize. I searched over stack overflow, but could not find what I did wrong. Following is a sample of what I'm doing:
namespace ConsoleApp2
{
[Flags]
[JsonConverter(typeof(StringEnumConverter))]
enum TestEnum
{
none = 0,
obj1 = 1,
obj2 = 2
}
class Program
{
static void Main(string[] args)
{
var jsonString = "{none}";
var deserializedObject = JsonConvert.DeserializeObject<TestEnum>(jsonString);
}
}
}
The exception I get on the deserialize line is Unexpected token StartObject when parsing enum.
I suspect it might be because I am representing the json string wrong, I also tried "{\"none\"}", "{\"TestEnum\":\"none\"}", "{TestEnum:none}", "{none}" and "none"
.