Open mmajcica opened 4 years ago
I'm trying to deserialize an enum but with no luck. Following a simple example of what is going wrong:
const string incomingStringFromMicroservice = @"{""Name"":""Greg"",""fruit"":""Apple""}"; var newtonsoftFruit = Newtonsoft.Json.JsonConvert.DeserializeObject<FruitPicker>(incomingStringFromMicroservice); var utf8Fruit = Utf8Json.JsonSerializer.Deserialize<FruitPicker>(incomingStringFromMicroservice);
where
public class FruitPicker { public string Name { get; set; } public Fruit Fruit { get; set; } } public enum Fruit { Orange = 0, Apple = 1 }
In the case of utf8json the Fruit is set to the default value. What I'm I doing wrong? Why is my enum not set correctly?
Thanks
I'm trying to deserialize an enum but with no luck. Following a simple example of what is going wrong:
where
In the case of utf8json the Fruit is set to the default value. What I'm I doing wrong? Why is my enum not set correctly?
Thanks