title: GSON Expected BEGIN_ARRAY but was BEGIN_OBJECT?
body: <p>I just start to learn about gson.
  I see lot of topic about this error, but i don't find any help or answer corresponding of my problem.</p>
  
  <p>I'm trying to parse a JSON string like this one:</p>
  
  <pre><code>{
  "CodeAnalytique": "XXXX",
    "Domaine": "XXXX",
    "HabilitationAD": [
      {
        "Key": "XXXX",
        "Value": [
          {
            "Applicatif": "XXXX",
            "Cle": "E",
            "Role": "Red",
            "Valeur": "XXXX"
          },
          {
            "Applicatif": "XXXX",
            "Cle": "E",
            "Role": "Red",
            "Valeur": "XXXX"
          }
          //lot of other value
          ]
      }
    ],
    "HabilitationInterprete": [
      {
        "Key": "XX",
        "Value": [
          {
            "Applicatif": "XXXX",
            "Cle": "Z",
            "Role": "Red",
            "Valeur": "XXX"
          },
          {
            "Applicatif": "XXXX",
            "Cle": "Z",
            "Role": "Red",
            "Valeur": "XXXX"
          }
          //lot of other value
          ]
      }
    ],
    "Identity": "XXXX",
    "InfoConsolidee": "Operation requested at XXXX",
    "IsAdminI": true,
    "IsAdminM": false,
    "IsAuthentif": true,
    "Matricule": "XXX",
    "Nom": "XXXX",
    "PasswordEnvoye": "XXXX",
    "Prenom": "XXX",
    "PrincipalPermissionMode": 1,
    "RoleSGBD": [
      "xxxx"
    ],
    "RoleSI": [
      null,
      "APP_02",
      "APP_03",
     //lot of other value
    ],
    "Societe": "XXX",
    "TypeClient": null
  }
  </code></pre>
  
  <p>into an objects</p>
  
  <pre><code>InfoSecuriteBean mInfoSecuriteBean = gson.fromJson(reader, InfoSecuriteBean.class);
  </code></pre>
  
  <p>Here's object class I'm using.</p>
  
  <pre><code>import com.google.gson.annotations.SerializedName;
  
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  public class InfoSecuriteBean {
  
      @SerializedName("IsAuthentif")
      private boolean mIsAuthentif = false;
  
      @SerializedName("PrincipalPermissionMode")
      private enumPrincipalPermissionMode mPrincipalPermissionMode;
      @SerializedName("RoleSGBD")
      private List&lt;String&gt; mRoleSGBD;
      @SerializedName("RoleSI")
      private List&lt;String&gt; mRoleSI;
      @SerializedName("Identity")
      private String mIdentity = null;
      @SerializedName("Password")
      private String mPassword = null;
      @SerializedName("InfoConsolidee")
      private String mInfoConsolidee = null;
  
      @SerializedName("IsAdminM")
      private boolean mIsAdminM = false;
      @SerializedName("IsAdminI")
      private boolean mIsAdminI = false;
  
      @SerializedName("Matricule")
      private String mMatricule = null;
      @SerializedName("Nom")
      private String mNom = null;
      @SerializedName("Prenom")
      private String mPrenom = null;
      @SerializedName("CodeAnalytique")
      private String mCodeAnalytique = null;
      @SerializedName("Domaine")
      private String mDomaine = null;
      @SerializedName("Societe")
      private String mSociete = null;
      @SerializedName("TypeClient")
      private String mTypeClient = null;
  
      @SerializedName("HabilitationAD")
      private Map&lt;String,List&lt;HabilitationBean&gt;&gt; mHabilitationAD = new HashMap&lt;String, List&lt;HabilitationBean&gt;&gt;();
      @SerializedName("HabilitationInterprete")
      private Map&lt;String,List&lt;HabilitationBean&gt;&gt; mHabilitationInterprete = new HashMap&lt;String, List&lt;HabilitationBean&gt;&gt;();
  //Getter and setter
  </code></pre>
  
  <p>and the other object use</p>
  
  <pre><code>import com.google.gson.annotations.SerializedName;
  
  public class HabilitationBean
  {
      @SerializedName("Applicatif")
      private String mApplicatif = null;
      @SerializedName("Role")
      private String mRole = null;
      @SerializedName("Cle")
      private String mCle = null;
      @SerializedName("Valeur")
      private String mValeur = null;
  
  //getter and setter
  </code></pre>
  
  <p>But it throws me with</p>
  
  <pre><code>com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECTat line 1 column 60
  </code></pre>
  
  <p>Any ideas how should I fix it?</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 60 path $.HabilitationAD[0]
              at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:200)
              at com.google.gson.Gson.fromJson(Gson.java:810)
              at com.google.gson.Gson.fromJson(Gson.java:748)
              at com.sig.webservice.WebSecurityGBD.doInBackground(WebSecurityGBD.java:69)
              at com.sig.webservice.WebSecurityGBD.doInBackground(WebSecurityGBD.java:23)
              at android.os.AsyncTask$2.call(AsyncTask.java:292)
              at java.util.concurrent.FutureTask.run(FutureTask.java:237)
              at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
              at java.lang.Thread.run(Thread.java:818)
       Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 60 path $.HabilitationAD[0]
              at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:350)
              at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:172)
              at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145)
              at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103)
              at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196)
              at com.google.gson.Gson.fromJson(Gson.java:810)
              at com.google.gson.Gson.fromJson(Gson.java:748)
              at com.sig.webservice.WebSecurityGBD.doInBackground(WebSecurityGBD.java:69)
              at com.sig.webservice.WebSecurityGBD.doInBackground(WebSecurityGBD.java:23)
              at android.os.AsyncTask$2.call(AsyncTask.java:292)
              at java.util.concurrent.FutureTask.run(FutureTask.java:237)
              at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
              at java.lang.Thread.run(Thread.java:818)
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>The problem come from the two HashMap></p>
  
  <pre><code> @SerializedName("HabilitationAD")
          private Map&lt;String,List&lt;HabilitationBean&gt;&gt; mHabilitationAD = new HashMap&lt;String, List&lt;HabilitationBean&gt;&gt;();
          @SerializedName("HabilitationInterprete")
          private Map&lt;String,List&lt;HabilitationBean&gt;&gt; mHabilitationInterprete = new HashMap&lt;String, List&lt;HabilitationBean&gt;&gt;(); 
  </code></pre>
  
  <p>if i comment this properties i don't have any probleme to build my json objet.</p>
  
  <p>I found this link <a href="https://stackoverflow.com/questions/14263114/deserializing-a-mapstring-object-field-with-gson">Deserializing a Map&lt;String, Object&gt; field with Gson</a> </p>
  
  <p>Currently i try something like this</p>
  
  <pre><code>public class InfoSecuriteBeanDeserializer implements JsonDeserializer&lt;InfoSecuriteBean&gt; {
  
      @Override
      public InfoSecuriteBean deserialize(JsonElement json, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
  
          JsonArray jArray = (JsonArray) json;
  
          InfoSecuriteBean mInfoSecuriteBean = new InfoSecuriteBean();
  
          for (int i=1; i&lt;jArray.size(); i++) {
              JsonObject jObject = (JsonObject) jArray.get(i);
              //assuming you have the suitable constructor...
              HabilitationBean mHabilitationBean = new HabilitationBean(jObject.get("Applicatif").getAsString(),
                      jObject.get("Cle").getAsString(),
                      jObject.get("Role").getAsString(),
                      jObject.get("Valeur").getAsString());
              mInfoSecuriteBean.getmHabilitationAD().add(mHabilitationBean);
          }
  
          return mInfoSecuriteBean;
      }
  }
  </code></pre>
  
  <p>Do you think i'm in the good way to resolve my problem ?</p>