title: Mapping nested JSON with Java class using Gson
body: <p>The json is</p>
  <pre><code>{
      &quot;a&quot;: &quot;Y&quot;,
      &quot;b&quot;: &quot;Y&quot;,
      &quot;c&quot;: &quot;Y&quot;,
      &quot;d&quot;: &quot;Y&quot;,
      &quot;someList&quot;: [
          {
              &quot;id&quot;: &quot;somevalue&quot;
          },
           
          {
              &quot;id&quot;: &quot;somevalue&quot;
          }
      ]
  }
  </code></pre>
  <p>for that my java class model is</p>
  <pre><code>class Response
     String a,b,c,d;
     ArrayList&lt;Id&gt; idList;
     
    //along with getters and setters.
  </code></pre>
  <p>and below is the implementation of Id class</p>
  <pre><code>public class Id {
      private String id;
  
      public String getid() {
          return id;
      }
  
      public void setid(String id) {
          this.id = id;
      }
  }
  
  </code></pre>
  <p>Now i parse this as below in a servlet class.</p>
  <pre><code>Response details = new Gson().fromJson(request.getReader(),Response.class);
  </code></pre>
  <p>when i print all the string variables like a,b,c,d, it prints
  but when i try to print the list like</p>
  <pre><code>System.out.println(details.getidList());
  
  </code></pre>
  <p>The result is something like Id@57eff207.ie. it prints the memory location.
  Now is there any problem with my class structure?. why not able to map the arraylist?</p>
  <p>Please help me. Thanks in advance.</p>