Have a program that calls up a URL of JSON data and loads it in and then starts processing it record by record. That said, sometimes the result can be just a header with no data for various reasons. When I try to process the results I end up getting the below due to no data:
- Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
- at ShowWebsiteDownloader.Program.Main() in C:\Users\jriker\source\repos\ShowWebsiteDownloader\ShowWebsiteDownloader\Program.cs:line 97
So I read in the data:
- rawJSON = webClient.DownloadString(showsurls);
- ShowWebsiteDownloader.Rootobject rootObject = JsonConvert.DeserializeObject<ShowWebsiteDownloader.Rootobject>(rawJSON);
Then process the results
- for (int loop = 0; loop < rootObject.tiles.Length; loop++)
- {
So the before mentioned error is on the start of the for loop. Is there a way to check if any data exists after Deserializing?