I have the following JSON chunk (extracted from the full JSON in order to simplify the question):
"statistics": [
{
"Strength": {
"min": 16,
"max": 20
}
},
{
"Dexterity": {
"min": 16,
"max": 20
}
}]
I'd like to deserialize the "statistics" array into a C# array of "Statistic" objects, but I can"t find how to do it... The key of each statistic object can be anything : "Strength","Luck","Dexterity" and so on, and each of those keys are unique.
The C# data object would be like this :
public class Container
{
public Statistic[] Statistics { get; set; }
}
public class Statistic
{
//Contains the name of the statistic
public string Name { get; set; }
public int Min { get; set; }
public int Max { get; set; }
}
Maybe can I use some kind of polymorphism by removing the Name
property and creating all possible classes of statistics, but it deafeats the adaptability of my code.
Thank you a lot.