title: How to access JSON elements in a subarray using C#
body: <p>Currently I am using C# like so to access a particular endpoint from a sports statistics API</p>
  <pre><code>class GetPlayerData
  {
      public string retrievePlayerStats()
      {
          var URL = new UriBuilder(&quot;https://statsapi.web.nhl.com/api/v1/people/8471698/stats?stats=statsSingleSeason&amp;season=20202021&quot;);
  
          var client = new WebClient();
  
          dynamic PlayerData = JObject.Parse(client.DownloadString(URL.ToString()));
  
          string PlayerStats = PlayerData.stats.ToString();
  
          return PlayerStats;
      }
  }
  </code></pre>
  <p>The call works with no issue returning the following result seen formatted at the link below:</p>
  <p><a href="https://statsapi.web.nhl.com/api/v1/people/8471698/stats?stats=statsSingleSeason&amp;season=20202021" rel="nofollow noreferrer">https://statsapi.web.nhl.com/api/v1/people/8471698/stats?stats=statsSingleSeason&amp;season=20202021</a></p>
  <p>My question is how do I access the items in the sub-array &quot;splits&quot;.  I want to be able to bring back a single stat for the player like goals or time on ice.  If I try the commented options below I receive an error that says &quot;Cannot perform runtime binding on a null reference&quot;.  I am fairly new to C# so hopefully the answer is easy and any help (or even other options completely) on how to do this is much appreciated.</p>
  <pre><code>public string retrievePlayerStats()
  {
      var URL = new UriBuilder(&quot;https://statsapi.web.nhl.com/api/v1/people/8471698/stats?stats=statsSingleSeason&amp;season=20202021&quot;);
  
      var client = new WebClient();
  
      dynamic PlayerData = JObject.Parse(client.DownloadString(URL.ToString()));
  
      string PlayerName = PlayerData.stats.ToString();
      //string PlayerName = PlayerData.splits.ToString(); --null reference error
      //string PlayerName = PlayerData.stats.splits.ToString(); --null reference error
  
      return PlayerName;
  }
  </code></pre>
  <p>Thank you!</p>