title: C# JSON error => Cannot deserialize JSON object into type 'System.Collections.Generic.IEnumerable`1
body: <p>I am trying to access a .json endpoint with this line of code inside <code>Main()</code>:</p>
  
  <pre><code>var RM= ParseArrayFromWeb&lt;RM&gt;("http://myendpoint.json").ToArray();              
  </code></pre>
  
  <p>Here is the <code>ParseArrayFromWeb</code> function that is defined above/outside of MAIN()</p>
  
  <pre><code>public static IEnumerable&lt;T&gt; ParseArrayFromWeb&lt;T&gt;(string url)
  {
      var webRequest = WebRequest.Create(url);
      using (var response = webRequest.GetResponse())
      {
          if (response != null)
          {
              var stream = response.GetResponseStream();
              if (stream != null)
              {
                  using (var reader = new StreamReader(stream))
                  {
                      return JsonConvert.DeserializeObject&lt;IEnumerable&lt;T&gt;&gt;(reader.ReadToEnd());
                  }
              }
          }
          throw new WebException("Options request returned null response");
      }
  }
  </code></pre>
  
  <p>Here is the RM class that is defined above/outside of Main() that should hold the json fields returned:</p>
  
  <pre><code>public class RM
  {
  
      public string calculation_method { get; set; } 
      public double? related_master_id { get; set; }
      public string related_master_name { get; set; }
      public string parameter_file_date { get; set; } 
      public string exchange_complex { get; set; }
      public string combined_commodity_code { get; set; }
      public string currency { get; set; }
      public double? maintenance_margin { get; set; }
      public double? scanning_risk { get; set; }
      public double? spread_charge { get; set; }
      public double? spot_charge { get; set; }
      public double? inter_commodity_credit { get; set; }
      public double? short_option_minimum { get; set; }
      public double? scenario_number { get; set; }
      public double? initial_margin { get; set; }
      public string exchange_code { get; set; } 
      public string product_description { get; set; }
      public string error_description { get; set; }
  }
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <blockquote>
    <p>Cannot deserialize JSON object into type 'System.Collections.Generic.IEnumerable`1[JSON.Program+RM]'.</p>
  </blockquote>
  
  <p>HERE is one row of the JSON:</p>
  
  <p>{"error_description":"error 454",
  "combined_commodity_code":"xx",
  "exchange_complex":"x",
  "exchange_code":"x",
  "initial_margin":null,
  "maintenance_margin":null,
  "scanning_risk":null,
  "spread_charge":null,
  "spot_charge":null,
  "currency":null,"
  inter_commodity_credit":0},</p>
  
  <p>Notice not all fields are present. That is ok. I have to handle that.</p>
  
  <p>Any ideas?</p>
  
  <p>Thank you.</p>