I successfully deserialize JSON File and I'm getting the results but after the end of results I'm getting 'object not set to instance of an object` error
JSON File:
"radiant_team": {
"team_name": "EHOME",
"team_id": 4,
"team_logo": 52122954231169668,
"complete": true
},
"dire_team": {
"team_name": "Team Secret",
"team_id": 1838315,
"team_logo": 543025270456493033,
"complete": true
public partial class LiveLeagues
{
public LiveGames Result { get; set; }
}
public class LiveGames
{
public List<GameStats> games { get; set; }
public int status { get; set; }
}
public class GameStats
{
public List<BasePlayer> players { get; set; }
public RadiantTeam radiant_team { get; set; }
public DireTeam dire_team { get; set; }
}
public class DireTeam
{
public string team_name { get; set; }
public int team_id { get; set; }
public object team_logo { get; set; }
public bool complete { get; set; }
}
public class RadiantTeam
{
public string team_name { get; set; }
public int team_id { get; set; }
public object team_logo { get; set; }
public bool complete { get; set; }
}
LiveLeagues.LiveLeagues liveGames = JsonConvert.DeserializeObject<LiveLeagues.LiveLeagues>(response.Content.ReadAsStringAsync().Result);
foreach (var leagues in liveGames.Result.games)
{
MessageBox.Show(leagues.dire_team.team_id.ToString());
MessageBox.Show(leagues.radiant_team.team_id.ToString());
}
I tried to iterate through the JSON and test if the values will show. I tested it on MessageBox.Show and I got the result "EHOME" and "Team Secret" but after that the error comes up 'object not set to instance of an object`
response.Content.ReadAsStringAsync().Resultthat is most certainly wrong.