title: Deserializing 2D array of objects JSON to Java
body: <p>I'm using GSON to deserialize my JSON string. It seems to choke when attempting to deserialize a 2D array of objects. Here's the bit:</p>
  
  <pre><code>{ .
    ..
    ...
    "states": [
              {"SPAWNINGPHASE": [{"name": "STATEA", "duration": 4}, {"name": "STATEB", "duration": 4}]},
              {"ALIVEPHASE": [{"name": "STATEA", "duration": 5}, {"name": "STATEB", "duration": 4}]}
              ]
  }
  </code></pre>
  
  <p>The above is a part of a bigger JSON.
  I get <code>Expected BEGIN_ARRAY but was BEGIN_OBJECT</code>
  I've looked over my JSON, but I don't see where it's incorrect</p>
  
  <pre><code>Group g=gson.fromJson(configFile, Group.class);
  </code></pre>
  
  <p>That's what I use to start the read. Is this not enough to process the string for the 2D array?</p>
  
  <p>In Group.class I tried both </p>
  
  <pre><code>public State[][] states;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public List&lt;List&lt;State&gt;&gt; states;
  </code></pre>
  
  <p>Everything else seems to deserialize fine. </p>
  
  <p>Do I have to use this (below)?</p>
  
  <pre><code>Type collectionType = new TypeToken&lt;Collection&lt;Integer&gt;&gt;(){}.getType();
  Collection&lt;Integer&gt; ints2 = gson.fromJson(json, collectionType);
  </code></pre>