title: How to dynamically handle json response array/object using Gson
body: <p>I am facing a problem , sometimes Json response returns an array of objects , sometimes object itself , how we can handle dynamically in the response class.
  In the current eg :results sometimes gets an array of objects </p>
  
  <pre><code> "\"results\": " +
              "[{" +
  </code></pre>
  
  <p>and sometimes object itself</p>
  
  <pre><code> "\"results\": " +
              "{" +
  </code></pre>
  
  <p>Eg:</p>
  
  <p>How we can handle this ?</p>
  
  <pre><code>Gson gson = new Gson();
      SearchResponse response=new SearchResponse();
      response= gson.fromJson("{" +
              "\"completed_in\": 0.047," +
              "\"max_id\": 291771567376039936," +
              "\"max_id_str\": \"291771567376039936\"," +
              "\"next_page\": \"?page=2&amp;max_id=291771567376039936&amp;q=javacodegeeks\"," +
              "\"page\": 1," +
              "\"query\": \"javacodegeeks\"," +
              "\"refresh_url\": \"?since_id=291771567376039936&amp;q=javacodegeeks\"," +
              "\"results\": " +
              "{" +
              "\"created_at\": \"Thu, 17 Jan 2013 04:58:57 +0000\"," +
              "\"from_user\": \"hkokko\"," +
              "\"from_user_id\": 24726686," +
              "\"from_user_id_str\": \"24726686\"," +
              " \"from_user_name\": \"Hannu Kokko\"," +
              " \"geo\": null," +
              "\"id\": 291771567376039936," +
              "\"id_str\": \"291771567376039936\"," +
              "\"iso_language_code\": \"en\"," +
              " \"metadata\": {" +
              "\"result_type\": \"recent\"}," +
              "\"profile_image_url\": \"hjh\"," +
              "\"profile_image_url_https\": \"kkj\"," +
              "\"source\": \"&amp;lt;a href=&amp;quot;hj;\"," +
              "\"text\": \"Continuous Deployment: Are You Afraid It Might Work? jh\"," +
              "\"to_user\": null," +
              "\"to_user_id\": 0," +
              "\"to_user_id_str\": \"0\"," +
              "\"to_user_name\": null" +
              " }," +
              "\"results_per_page\": 15," +
              "\"since_id\": 0," +
              "\"since_id_str\": \"0\"" +
              "}", SearchResponse.class);
      System.out.println(response.toString());
  </code></pre>
  
  <p>Kindly assist...</p>
  
  <p>Can anyone give any suggestions by using different jars to achieve this?</p>