title: Im getting this error: The type of the expression must be an array type but it resolved to Object
body: <p><em><strong>I need to take the &quot;id&quot; from &quot;weather&quot; part, that come from json file.</strong></em></p>
  <p>I know that i have to take the first element but I don't know how to do it. How i get first element using get method?</p>
  <p>A part weatherMap all code works fine! Try it out and let me know what's the problem</p>
  <p><strong>Java file</strong></p>
  <pre><code>import java.util.Map;
  import java.util.HashMap;
  import java.net.*;
  
  import com.google.gson.*;
  import com.google.gson.reflect.*;
  public static Map&lt;String, Object&gt; jsonToMap(String str) {
    Map&lt;String, Object&gt; map = new Gson().fromJson(
      str, new TypeToken&lt;HashMap&lt;String, Object&gt;&gt;() {}.getType()
    );
    return map;
  }
  
  
  StringBuilder result = new StringBuilder();
  URL url = new URL(urlString);
  URLConnection conn = url.openConnection();
  BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  String line;
  while ((line = rd.readLine()) != null) {
    result.append(line);
  }
  rd.close();
  
  Map&lt;String, Object&gt; weatherMap = jsonToMap(respMap.get(&quot;weather&quot;)[0].toString());
  System.out.println(&quot;ID logo: &quot; + weatherMap.get(&quot;icon&quot;));
  </code></pre>
  <p><strong>Json file</strong></p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;coord&quot;: {
      &quot;lon&quot;: 12.84,
      &quot;lat&quot;: 45.78
    },
    &quot;weather&quot;: [
      {
        &quot;id&quot;: 800,
        &quot;main&quot;: &quot;Clear&quot;,
        &quot;description&quot;: &quot;clear sky&quot;,
        &quot;icon&quot;: &quot;01d&quot; // I need this
      }
    ],
    &quot;base&quot;: &quot;stations&quot;,
    &quot;main&quot;: {
      &quot;temp&quot;: 16.67,
      &quot;feels_like&quot;: 16.35,
      &quot;temp_min&quot;: 16.11,
      &quot;temp_max&quot;: 17.22,
      &quot;pressure&quot;: 1019,
      &quot;humidity&quot;: 64
    },
    &quot;visibility&quot;: 10000,
    &quot;wind&quot;: {
      &quot;speed&quot;: 0.45,
      &quot;deg&quot;: 230,
      &quot;gust&quot;: 1.34
    },
    &quot;clouds&quot;: {
      &quot;all&quot;: 0
    },
    &quot;dt&quot;: 1603033884,
    &quot;sys&quot;: {
      &quot;type&quot;: 3,
      &quot;id&quot;: 2003804,
      &quot;country&quot;: &quot;IT&quot;,
      &quot;sunrise&quot;: 1602998965,
      &quot;sunset&quot;: 1603037863
    },
    &quot;timezone&quot;: 7200,
    &quot;id&quot;: 3170086,
    &quot;name&quot;: &quot;Portogruaro&quot;,
    &quot;cod&quot;: 200
  }
  </code></pre>