title: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
body: <p>I am trying to read and parse a JSON string which starts as an array (e.g. <code>[{test: "test"}]</code>) and I keep running into the error: </p>
  
  <pre><code>Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
  </code></pre>
  
  <p>The error in my log points to this line:</p>
  
  <pre><code>Gson gson = new GsonBuilder().create();
  PayoutCharges payoutList = gson.fromJson(reader, PayoutCharges.class);
  </code></pre>
  
  <p>Following some stackoverflow answers, I created the PayoutCharges class as an array list of PayoutCharge. <strong>How do I fix this issue so that GSON knows that the JSON string is inside an array?</strong></p>
  
  <p><strong>PayoutCharges.java</strong></p>
  
  <pre><code>package com.app.driver.entity;
  
  import java.util.ArrayList;
  
  import com.google.gson.annotations.SerializedName;
  
  public class PayoutCharges {
      //handle error
      @SerializedName("error")
      private Error mError;
  
      public Error getError() {
          return mError;
      }
  
      public void setError(Error error) {
          mError = error;
      }
  
      //handle data
      @SerializedName("payoutCharges")
      private ArrayList&lt;PayoutCharge&gt; mPayoutCharges;
  
      public ArrayList&lt;PayoutCharge&gt; getPayoutCharges() {
          return mPayoutCharges;
      }
  
      public void setPayoutCharges(ArrayList&lt;PayoutCharge&gt; payoutCharges) {
          mPayoutCharges = payoutCharges;
      }
  }
  </code></pre>
  
  <p>After reading @Ridcully's response, I want to ask if there is a way for me to update <code>PayoutCharges.java</code> so that it knows that the JSON is an array. Something like <code>@SerializedName([])</code>?</p>