Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Deserializing a number from a Json file into an Enum

I am having issues deserializing a number into an Enum using JsonConvert.
In other words, I am trying to do exactly what is in this thread.
The problem is that not only it dates from 2015, but also that nobody provided an actual answer to that thread.

I also looked at a couple of other similar threads, but they are not quite solving my issue. As you can see from the above link, the idea is to reconstruct an object when de-serializing and pass in an Enum to the constructor.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

the tread contains only one class parameter, so I deserialized parameters without any problem, enumerations were deserialized correctly too

using Newtonsoft.Json;

List<Parameter> parameters = JArray.Parse(json)[0]["Tests"][0]["Parameters"]
                                                      .ToObject<List<Parameter>>();
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading