title: How to convert a JSON file to a readable object in Java
body: <p>I am new to Java. I have the following .json file with the following kind of contents:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;res&quot;: [
      {
        &quot;test1&quot;: &quot;323dfer&quot;,
        &quot;test2&quot;: &quot;adqdcr2c&quot;
      },
      {
        &quot;test1&quot;: &quot;23cr2c2c&quot;,
        &quot;test2&quot;: &quot;23rv2rvc&quot;
      }
    ]
  }
  </code></pre>
  <p>And currently I am accessing this file like so:</p>
  <pre class="lang-java prettyprint-override"><code>InputStream jsonfile= this.getClass().getClassLoader().getResourceAsStream(&quot;test.json&quot;);
  
  assert jsonfile!= null;
  ObjectMapper mapper = new ObjectMapper();
  Map jsonMap = mapper.readValue(jsonfile, Map.class);
  
  Object records = jsonMap.get(&quot;res&quot;);
  System.out.println(records);
  </code></pre>
  <p>which results in this output:</p>
  <pre class="lang-none prettyprint-override"><code>[{test1=323dfer, test2=adqdcr2c}, {test1=23cr2c2c, test2=23rv2rvc}]
  </code></pre>
  <p>However, I am now not sure how to access the second object in the array and loop trough the keys, e.g. test1 and test2, etc.</p>
  <p>I am wondering if anyone can help with this?</p>