title: Converting JSON to C# involving a large number of nested JSON objects
body: <p>I would like to convert (deserialize) JSON into C#. I have taken a stab at it by creating a C# file that will handle the serialization and deserializtion.</p>
  <p>Given a JSON file that contains</p>
  <pre><code>{
      &quot;Meta Data&quot;: {
          &quot;1. Information&quot;: &quot;Weekly Prices (open, high, low, close) and Volumes&quot;,
          &quot;2. Symbol&quot;: &quot;IBM&quot;,
          &quot;3. Last Refreshed&quot;: &quot;2020-06-26&quot;,
          &quot;4. Time Zone&quot;: &quot;US/Eastern&quot;
      },
      &quot;Weekly Time Series&quot;: {
          &quot;2020-06-26&quot;: {
              &quot;1. open&quot;: &quot;122.1200&quot;,
              &quot;2. high&quot;: &quot;122.9000&quot;,
              &quot;3. low&quot;: &quot;115.8800&quot;,
              &quot;4. close&quot;: &quot;117.1900&quot;,
              &quot;5. volume&quot;: &quot;35016186&quot;
          },
          &quot;2020-06-19&quot;: {
              &quot;1. open&quot;: &quot;119.1900&quot;,
              &quot;2. high&quot;: &quot;127.5000&quot;,
              &quot;3. low&quot;: &quot;118.2900&quot;,
              &quot;4. close&quot;: &quot;122.4700&quot;,
              &quot;5. volume&quot;: &quot;24867689&quot;
          },
          &quot;2020-06-12&quot;: {
              &quot;1. open&quot;: &quot;132.2700&quot;,
              &quot;2. high&quot;: &quot;135.8800&quot;,
              &quot;3. low&quot;: &quot;117.8352&quot;,
              &quot;4. close&quot;: &quot;121.9100&quot;,
              &quot;5. volume&quot;: &quot;33456639&quot;
          },
          [...]
  
          &quot;2000-07-07&quot;: {
              &quot;1. open&quot;: &quot;108.7500&quot;,
              &quot;2. high&quot;: &quot;109.8700&quot;,
              &quot;3. low&quot;: &quot;100.0000&quot;,
              &quot;4. close&quot;: &quot;105.0600&quot;,
              &quot;5. volume&quot;: &quot;38608400&quot;
          }
      }
  }
  
  </code></pre>
  <p>[...] being a large number of objects</p>
  <p>the file:
  <a href="https://www.alphavantage.co/query?function=TIME_SERIES_WEEKLY&amp;symbol=IBM&amp;apikey=demo" rel="nofollow noreferrer">https://www.alphavantage.co/query?function=TIME_SERIES_WEEKLY&amp;symbol=IBM&amp;apikey=demo</a></p>
  <p>Here is my C# classes.
  I can't figure out how to</p>
  <ol>
  <li>Convert the JSON object names into proper C# variables ex &quot;1. open&quot; -&gt; &quot;open&quot;</li>
  <li>Deserialize</li>
  </ol>
  <pre><code>    public class PeriodData
      {
          public string open { get; set; }
          public string high { get; set; }
          public string low { get; set; }
          public string close { get; set; }
          public string volume { get; set; }
      }
      
      public class Period
      {
          private IEnumerable&lt;PeriodData&gt; periodData { get; set; }
      }
      
      public class MetaData
      {
          public string info { get; set; }
          public string symbol { get; set; }
          public string lastRefreshed { get; set; }
          public string timeZone { get; set; }
      }
      
      public class Root
      {
          public MetaData metaData { get; set; }
          public Period period { get; set; }
      }
  </code></pre>
  <p>If I was to deserialize the JSON object I would call</p>
  <pre><code>HttpClient client = new HttpClient(); //Create a client to retrieve the file
  var JSONserverdata = client.GetStringAsync(url); // Get the stock data
                                                   // url -&gt;location of the file on the server
  var Cdata = JsonConvert.DeserializeObject&lt;Root&gt;(JSONserverdata) //Deserialize the stock data into C#
  </code></pre>
  <p><em>I don't need to serialize this object but if you want to answer that, go ahead</em></p>