title: How to deal with API sometimes returning a property as an array and sometimes as an object?
body: <p>Can anyone see the problem here? the object &quot;OrderItemPayment&quot; becomes an array for some reason during deserialisation?</p>
  <p>When I try to deserialize a response that looks like this:</p>
  <p><a href="https://i.stack.imgur.com/UZ5Q9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UZ5Q9.png" alt="enter image description here" /></a></p>
  <p>I get this result:</p>
  <pre><code>{
     &quot;items&quot;:[
        {
           &quot;created_at&quot;:&quot;2021-01-28 18:37:45&quot;,
           &quot;payment&quot;:[
              
           ]
        },
        {
           &quot;created_at&quot;:&quot;2021-01-28 16:06:23&quot;,
           &quot;payment&quot;:[
              
           ]
        }
     ]
  }
  </code></pre>
  <p><strong>My classes</strong></p>
  <pre><code>[Serializable]
  public class Order
  {
      [JsonProperty(&quot;items&quot;)]
      public OrderItem[]? Items { get; set; }
  }
  
  [Serializable]
  public class OrderItem
  {
      [JsonProperty(&quot;created_at&quot;)]
      public string? CreatedAt { get; set; }
      [JsonProperty(&quot;payment&quot;)]
      public OrderItemPayment Payment { get; set; } = new OrderItemPayment();
  }
  [Serializable]
  public record OrderItemPayment
  {
      [JsonProperty(&quot;amount_paid&quot;)]
      public decimal AmountPaid { get; set; }
      [JsonProperty(&quot;shipping_captured&quot;)]
      public decimal ShippingCaptured { get; set; }
  }
  </code></pre>
  <p><em>My result:</em>
  <a href="https://i.stack.imgur.com/oxBv3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oxBv3.png" alt="enter image description here" /></a></p>