title: How do I return a List<Object> from a JSON like this?
body: <p>I'm making a webapp using Giant Bomb API.</p>
  
  <p>I'm stuck because I need to get a list of search results from GET request (using Unirest) and then convieniently convert it to a List of Objects called suggestions.</p>
  
  <p>Here's where my problem is:</p>
  
  <pre><code>private List&lt;Suggestion&gt; suggestions = new ArrayList&lt;&gt;();
  
  public List&lt;Suggestion&gt; searchGames(){
  
      HttpResponse&lt;String&gt; request;
      try {
      request = Unirest.get("http://giantbomb.com/api/search/?api_key=xxxxxxxxxxxxxxxxxxxxxxxxx&amp;format=json&amp;resources=game&amp;limit=10&amp;field_list=name&amp;query=creed")
                  .header("Accept", "application/json")
                  .asString();
  
      String requestString = request.toString(); //I can get my request as String, but that doesnt change much, I guess
  
      //&gt;&gt;&gt; the problematic part &lt;&lt;&lt;
  
      return suggestions;
  }
  </code></pre>
  
  <p>I'm missing something that would allow me to convert JSON response from Unirest to a List. Here's what I tried:</p>
  
  <ul>
  <li>GSON - problems with JSON format (there's some data in the beginning of JSON because of the fields with Limit, Offset and so on)</li>
  <li>Object Mapper (Unirest/Jackson) - problems since I get httpResponse  instead of String/Object/JsonNode etc.</li>
  <li>using JSONObject, JSONArray and for loop - no luck as well.</li>
  </ul>
  
  <p>My JSON from Unirest call looks pretty much like this:</p>
  
  <pre><code> {
          "error": "OK",
          "limit": 10,
          "offset": 0,
          "number_of_page_results": 1,
          "number_of_total_results": 3,
          "status_code": 1,
          "results": [
              {
                  "name": "Assassin's Creed",
                  "resource_type": "game"
              },
              {
                  "name": "The Creed",
                  "resource_type": "game"
              },
              {
                  "name": "Assassin's Creed: Lost Legacy",
                  "resource_type": "game"
              }
          ]
  }
  </code></pre>
  
  <p>I have a similar solution for Game class where I display List called games.</p>
  
  <pre><code>private List&lt;Game&gt; games = new ArrayList&lt;&gt;();
  
  public List&lt;Game&gt; getAllGames(){
      return games;
  }
  </code></pre>
  
  <p>I populate this list using a GET requests where I enter id and title.</p>
  
  <p>Suggestions coming from Giant Bomb API are trickier for me, since I'm using external API to get a list of objects, instead of entering my input data.</p>
  
  <p>My Suggestion.java class looks like this:</p>
  
  <pre><code>package rest.library;
  
  
  public class Suggestion {
  
      private long id;
      private String name;
  
      public Suggestion(){
      }
  
      public Suggestion(long id, String name) {
          this.id = id;
          this.name = name;
      }
  
      public long getId() {
          return id;
      }
  
      public String getName() {
          return name;
      }
  
  }
  </code></pre>
  
  <p>In my Controller I want to do this:</p>
  
  <pre><code>@RequestMapping("/search")
  public List&lt;Suggestion&gt; searchGames() { return gameService.searchGames(); }
  </code></pre>
  
  <p>Going under localhost:8080/search should return a List of Objects with search results gained from JSON request. It should look just like localhost:8080/games that returns me a list of games that I've sent using GET on Postman. I know that I get field "resource_type" from the API and there is no "id" field, but that's a problem for later since I think that filling selected class fields and adding id incrementaly won't be that much of a problem.</p>