So I'm working on a API wrapper with C#, I deserialize JSON data to a response model class using Newtonsoft.Json library. In the response model class, I have a list of sub-items, which each of contain a list of sub-items. These are defined like this:
public List<StatModel> Stats { get; set; }
each StatModel has a property which basically equals the name:
public Stat Stat { get; set; }
these are automatically deserialized, because each Stat is defined in an enum like this:
[EnumMember(Value = "Avg Walk Distance")]
AverageWalkDistance,
Now the problem is, if something changes in the actual API, the wrapper doesn't work since it doesn't have definition for the specified Stat. So this means if they add a new Stat to the API, the wrapper won't work until I manually add definition for it, like in the above code block.
So the question is, how can I ignore values that don't have corresponding Stat property available, or can I somehow re-design the whole thing so this doesn't happen? I'm guessing I have to define all new values by myself either way.
Here's the project on GitHub to get a better understanding of what I actually mean: https://github.com/eklypss/PUBGSharp
The Requester does the deserializing and returns a StatResponse, which has a list of sub-items called StatsRoot which each have their own list of StatModels which are the actual stat objects causing this issue. Each type of Stat is defined in the Enum/Stat.cs file.