[Help] JSON.Net Deserialization and the Riot Games API

I'm currently working on a project where I make a request to the Riot Games API, parse the JSON, and do some stuff with it. I have the request working, and I know I'm getting valid JSON. My issue is using JSON.Net to deserialize the JSON. The JSON is of the following structure:

{"xarcies": { "id": 31933985, "name": "Xarcies", "profileIconId": 588, "revisionDate": 1450249383000, "summonerLevel": 30 }}

The class I'm trying to put this JSON data into is the following

[JsonObject(MemberSerialization.OptIn)] class Summoner { [JsonProperty("id")] public long id {get;set;} [JsonProperty("name")] public string name { get; set; } [JsonProperty("profileIconId")] public int profileIconId { get; set; } [JsonProperty("revisionDate")] public long revisionDate { get; set; } [JsonProperty("summonerLevel")] public long summonerLevel { get; set; } } 

The issue I'm having is that because I'm given a "xarcies" object, which is not a generic name but a name unique to the individual request I made, I would have to change the JsonProperty for the class I'm using if I wanted to get data for a different user. I'm out of ideas as to how to get around this. I don't know of any way I can set a generic JsonProperty.

by Xarcies via /r/csharp

Leave a Reply