title: Different JSON array response
body: <p>I have problems parsing two different JSON responses.</p>
  
  <p>1: This is the JSON response I get from a RESTful API:</p>
  
  <pre><code>{
    "gear": [
      {
        "idGear": "1",
        "name": "Nosilec za kolesa",
        "year": "2005",
        "price": "777.0"
      }, {
        "idGear": "2",
        "name": "Stresni nosilci",
        "year": "1983",
        "price": "40.0"
      }
    ]
  }
  </code></pre>
  
  <p>2: This response I get from my testing client. I was added some values to the list and then I used <code>gson.toJson</code> for testing output.</p>
  
  <pre><code>[
    {
      "idGear": "1",
      "name": "lala",
      "year": 2000,
      "price": 15.0
    }, {
      "idGear": "2",
      "name": "lala2",
      "year": 2000,
      "price": 125.0
    }
  ]
  </code></pre>
  
  <p>They are both valid, but the second one was successfully deserialize to object like this:</p>
  
  <pre><code>Type listType = new TypeToken&lt;List&lt;Gear&gt;&gt;() {}.getType();
  List&lt;Gear&gt; gears= (List&lt;Gear&gt;) gson.fromJson(json, listType); 
  </code></pre>
  
  <p>With the first one, I was trying to deserialize the same way but I get error.</p>
  
  <hr>
  
  <p><em>EDIT</em></p>
  
  <p>API Method:</p>
  
  <pre><code>@GET
  @Produces(MediaType.APPLICATION_JSON)
  public List&lt;Gear&gt; getGear() {
    List&lt;Gear&gt; gears = gearDAO.getGears();
    if (!gears.isEmpty()) {
      return gears;
    } else
      throw new RuntimeException("No gears");
  }
  </code></pre>
  
  <p>CLIENT serialization code:</p>
  
  <pre><code>List&lt;Gear&gt; list = new ArrayList&lt;Gear&gt;();
  Gear o = new Gear();
  o.setPrice(15);
  o.setYear(2000);
  o.setName("asds");
  Type listTypes = new TypeToken&lt;List&lt;Gear&gt;&gt;() {}.getType();
  gson.toJson(list, listTypes);
  </code></pre>