title: How to Deserialize a Json Array with C#?
body: <p>I use RestSharp to make a Rest API Call.</p>
  <pre><code>public class GetValues
  {
      public string Values{ get; set; }
  }
  
  public class JsonObjects
  {
      public List&lt;GetValues&gt; Values{ get; set; }
  }
  
  RestRequest restRequest = new RestRequest(&quot;api/tempCatalog/temp1&quot;, Method.GET);
  
  restRequest.AddHeader(&quot;Accept&quot;, &quot;application/json&quot;);
  restRequest.AddHeader(&quot;Content-Type&quot;, &quot;application/json&quot;);
  restRequest.AddHeader(&quot;Authorization&quot;, token);
  
  IRestResponse restResponse = clientRest.Execute(restRequest );
  string Content = restResponse.Content;
  
  JsonObjects.Values= JsonConvert.DeserializeObject&lt;JsonObjects&gt;(Content).Values;
  </code></pre>
  <p>I have the above code and it works.</p>
  <p>But when the JSON Rest Response contains an array it throws an Exception when deserializing.</p>
  <p>When the Rest Response is like this , sometimes ,</p>
  <pre><code>{ &quot;Fields&quot;: [ &quot;Value.temp&quot;, ] } 
  </code></pre>
  <p>I get this exception:</p>
  <blockquote>
  <p>Newtonsoft.Json.JsonSerializationException: 'Error converting value'</p>
  <p>ArgumentException: Could not cast or convert from System.String to Namespace.GetValues.</p>
  </blockquote>
  <p>When I say sometimes i mean that i use this Deserialize in multiple API calls this in the question was just an example</p>
  <p>These are some Json Arrays that I have as Rest response and I want to deserialize them.</p>
  <pre><code>{
    &quot;Fields&quot;: [
  
      &quot;Temp1.Value&quot;,
      &quot;Temp2.Value&quot;,
      &quot;Temp3.Value&quot;,
      &quot;Temp4.Value&quot;
    ]
  
  }
  </code></pre>
  <p>or these??</p>
  <pre><code>{
  
    &quot;Errors&quot;:
   [
      
  {
  
        &quot;ErrorCode&quot;: &quot;Temp Number&quot;,
        &quot;Message&quot;: &quot;Temp Message&quot;,
        &quot;TempName&quot;: &quot;Name&quot;
      }
  
    ],
  
  
    &quot;ValueErrors&quot;: []
  
  }
  </code></pre>
  <p>or these??</p>
  <pre><code>{
    
  &quot;Total&quot;: 1,
    
  &quot;Categories&quot;: [
      
  {
  
        &quot;Id&quot;: &quot;tempID&quot;,
        &quot;Name&quot;: &quot;tempName&quot;
      }
  
    ]
  
  }
  </code></pre>