title: Using GSON to parse a JSON array
body: <p>I have a JSON file like this:</p>
  
  <pre><code>[
      {
          "number": "3",
          "title": "hello_world",
      }, {
          "number": "2",
          "title": "hello_world",
      }
  ]
  </code></pre>
  
  <p>Before when files had a root element I would use:</p>
  
  <pre><code>Wrapper w = gson.fromJson(JSONSTRING, Wrapper.class);
  </code></pre>
  
  <p>code but I can't think how to code the <code>Wrapper</code> class as the root element is an array.</p>
  
  <p>I have tried using:</p>
  
  <pre><code>Wrapper[] wrapper = gson.fromJson(jsonLine, Wrapper[].class);
  </code></pre>
  
  <p>with: </p>
  
  <pre><code>public class Wrapper{
  
      String number;
      String title;
  
  }
  </code></pre>
  
  <p>But haven't had any luck. How else can I read this using this method?</p>
  
  <p>P.S I have got this to work using: </p>
  
  <pre><code>JsonArray entries = (JsonArray) new JsonParser().parse(jsonLine);
  String title = ((JsonObject)entries.get(0)).get("title");
  </code></pre>
  
  <p>But I would prefer to know how to do it (if possible) with both methods.</p>