title: Convert JSON to Map<String, String> using Jackson
body: <p>I need to consume some data from a REST API. It returns JSON in the body response like this:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;dados&quot;: [
          {
              &quot;pessoa&quot;: 81,
              &quot;HAB_TAC&quot;: &quot; &quot;,
              &quot;NOME_COMPL&quot;: &quot;Adriana Corsa&quot;,
              &quot;NOME_ABREV&quot;: &quot;Adriana Corsa&quot;,
              &quot;DT_NASC&quot;: &quot;21/02/1993&quot;,
              &quot;MUNICIPIO_NASC&quot;: &quot;006015&quot;,
              &quot;NOME_MUN_NASC&quot;: &quot;CURITIBA&quot;,
              &quot;UF_MUN_NASC&quot;: &quot;PR&quot;,
              &quot;IBGE_MUN_NASC&quot;: &quot;4106902&quot;
           }, 
           {
              &quot;pessoa&quot;: 53,
              &quot;HAB_TAC&quot;: &quot; &quot;,
              &quot;NOME_COMPL&quot;: &quot;Jose de Oliveira&quot;,
              &quot;NOME_ABREV&quot;: &quot;Jose de Oliveira&quot;,
              &quot;DT_NASC&quot;: &quot;14/05/1968&quot;,
              &quot;MUNICIPIO_NASC&quot;: &quot;008367&quot;,
              &quot;NOME_MUN_NASC&quot;: &quot;BARRA VELHA&quot;,
              &quot;UF_MUN_NASC&quot;: &quot;SC&quot;,
              &quot;IBGE_MUN_NASC&quot;: &quot;4202107&quot;
            }
         ], 
         &quot;quantidade&quot;:100
  }
  </code></pre>
  <p>Except I have 207 name/value pairs for each 'pessoa', not just 9.</p>
  <p>So, I'd like to convert this to something I can work with.</p>
  <p>The last line basically returns how many records is in the response. So I only work if I have more than 0 records.</p>
  <p>After that I need to convert the data (dados) part in a Map&lt;String, String&gt; and then only consume the data I want - I really don't want to create a class to store all the data.</p>
  <p>So far, what I have is:</p>
  <pre class="lang-java prettyprint-override"><code>            var responseStream = response.getEntity().getContent();
              BufferedReader reader = new BufferedReader(new InputStreamReader(responseStream));
              var responseBody = reader.readLine();
  
              var responseBodyMapper = new ObjectMapper(); //com.fasterxml.jackson.databind.ObjectMapper;
  
              Map&lt;String, Map&lt;String,Object&gt;&gt; map = responseBodyMapper.readValue(responseBody, Map.class);
              ArrayList&lt;String&gt; innerDataMap = (ArrayList&lt;String&gt;) map.get(&quot;dados&quot;);
              int responseCount = Integer.parseInt(String.valueOf(map.get(&quot;quantidade&quot;)));
  
              if (responseCount &gt; 0){
  
                  for (String line : innerDataMap){ //It throws exception here
                      System.out.println(line); 
                  }
  
              }
  </code></pre>
  <p>The exception that is thrown is <code>java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class java.lang.String (java.util.LinkedHashMap and java.lang.String are in module java.base of loader 'bootstrap')</code></p>
  <p>So I'm obviously doing something wrong.</p>
  <p>I can get data from the outer look (data/quantity) just fine - although I'm probably not doing in the right/optimized way. But at least it works.</p>
  <p>But I can't find a way to get the data inside <code>dados</code> and convert it to a Map so I can than later do something with it.</p>
  <p>I was trying to do it with Kotlin - since I'm trying to lear it, but it meant it was even harder.</p>
  <p>I've been struggling with for a few hours. Something so simple can't be this hard.</p>
  <p>Can anyone shed a light on what I'm doing wrong here?</p>
  <p>Thank you.</p>