I'm trying to populate the properties of this class:
public class Summoner
{
public int id { get; set; }
public string name { get; set; }
public int profileIconId { get; set; }
public int summonerLevel { get; set; }
public long revisionDate { get; set; }
}
With this JSON:
{"SummonerName":{"id":445312515,"name":"SummonerName","profileIconId":28,"summonerLevel":30,"revisionDate":140642312000}}
Using JSON.net with the following:
public static Summoner getRecentGames(string summonerId)
{
Summoner summoner = new Summoner();
try
{
using (var webClient = new System.Net.WebClient())
{
var json = webClient.DownloadString("https://eu.api.pvp.net/api/lol/euw/v1.4/summoner/by-name/"+summonerId+"?api_key="+api_key);
webClient.Dispose();
summoner = JsonConvert.DeserializeObject<Summoner>(json);
return summoner;
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
return null;
}
The properties are never assigned values, is it something to do with their being an outer object in the JSON when the values I need are inside the inner objects?
I'm a new programmer and so sorry if this is a silly mistake, thanks.