So I have some json I am trying to get into a referenceable object using the Newtonsoft Json library, but I am truly stumped on this one. Basically, my data looks like this:
{
"43086": [{
"name": "Karthus's Brigands",
"tier": "SILVER",
"queue": "RANKED_SOLO_5x5",
"entries": [{
"playerOrTeamId": "43086",
"playerOrTeamName": "Testy Test",
"division": "IV",
"leaguePoints": 77,
"wins": 130,
"isHotStreak": false,
"isVeteran": true,
"isFreshBlood": false,
"isInactive": false
}]
}]
}
When I try to create an object to hold this data, and use the DeserializeObject function, my object always ends up null, and there are no exceptions being thrown.
I tried creating the object by hand, but once I had trouble, I ran the returned json through json2csharp, it gives me this:
public class Entry
{
public string playerOrTeamId { get; set; }
public string playerOrTeamName { get; set; }
public string division { get; set; }
public int leaguePoints { get; set; }
public int wins { get; set; }
public bool isHotStreak { get; set; }
public bool isVeteran { get; set; }
public bool isFreshBlood { get; set; }
public bool isInactive { get; set; }
}
public class invalid_type43086
{
public string name { get; set; }
public string tier { get; set; }
public string queue { get; set; }
public List<Entry> entries { get; set; }
}
public class RootObject
{
public List<invalid_type43086> invalid_name43086 { get; set; }
}
I've had other issues with this API, where the objects arent recognized by that converter, so I cleaned those up, but still no dice.
This is the line of code I have for deserialization:
var leagueStats = JsonConvert.DeserializeObject<SummonerClasses.RootObject>(returnedData);
and as mentioned, leagueStats ends up null immediately after that. I have confirmed that returnedData actually holds the above json, so I am not sure what the problem is, especially since its not throwing any exceptions. Stepping through the code provided no insight.
I also tried using the PopulateObject method from the newtonsoft library, and building a dictionary, but that failed as well (I got an error about it not being able to serialize into a non-indexable object, but I am unsure what the specific error was because I blew away that code once it was clear it wasn't going to be successful either).
Does anybody have any advice? I am using this same implementation against other endpoints of this API, and it is working without issue. The only difference I noticed is that the list values of this response are wrapped in both [ and { brackets, where other endpoints return list values using just the { brackets.