title: How to deserialize JSON containing an array of objects with a single property name and value each into a c# model?
body: <p>I have the following model:</p>
  <pre><code>public class UserPtr
  {
      public int my_var1 { get; set; }
      public int my_var2 { get; set; }
      public int my_var3 { get; set; }
      public int my_var4 { get; set; }
  }
  </code></pre>
  <p>And some API response JSON which is:</p>
  <pre><code>[ 
      {
          &quot;name&quot;: &quot;my_var1&quot;,
          &quot;ptr&quot;: 1 // &quot;Value_my_var1&quot;
      },
      {
          &quot;name&quot;: &quot;my_var2&quot;,
          &quot;ptr&quot;: 2 // &quot;Value_my_var2&quot;
      },
      {
          &quot;name&quot;: &quot;my_var3&quot;,
          &quot;ptr&quot;: 3 // &quot;Value_my_var3&quot;
      },
      {
          &quot;name&quot;: &quot;my_var4&quot;,
          &quot;ptr&quot;: 4 // &quot;Value_my_var4&quot;
      }
  ]
  </code></pre>
  <p>I want to set <code>my_var1 = Value_my_var1, my_var2 = Value_my_var2, my_var3 = Value_my_var3</code></p>
  <p>Normally I would use:</p>
  <pre><code>JsonConvert.DeserializeObject&lt;UserPtr&gt;(strJson);
  </code></pre>
  <p>But when I do, I get the following exception:</p>
  <blockquote>
  <p>Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'UserPtr' because the type requires a JSON object (e.g. {&quot;name&quot;:&quot;value&quot;}) to deserialize correctly.
  To fix this error either change the JSON to a JSON object (e.g. {&quot;name&quot;:&quot;value&quot;}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.</p>
  </blockquote>
  <p>How can I deserialize this array of objects containing property names and values into my model?</p>