title: How do I use Google's Gson API to deserialize JSON properly?
body: <p>In short, this is a sketch of the JSON object I want to parse in JAVA:</p>
  
  <pre><code>{
      object1: {
              item1: //[String | Array | Object] ,
              item2: // ...
              //&lt;&gt; more items
      object2: { /* .. */ }
      //&lt;&gt; more objects
  }
  </code></pre>
  
  <p>These are the <em>POJO</em> s I created for parsing (I'll leave out the <code>import</code> statements for brevity's sake): </p>
  
  <p>(1) The representation of the complete JSON object</p>
  
  <pre><code>public class JObjectContainer {
  
      private List&lt;JObject&gt; jObjects ;
  
      public JObjectContainer() { }
  
      //get &amp; set methods
  
  }
  </code></pre>
  
  <p>(2) The representation of the nested objects:</p>
  
  <pre><code> public class JObject {
  
      private String id ;
      private List&lt;JNode&gt; jObjects ;
  
      public JObject() { } 
  
      //get &amp; set methods
  
  }
  </code></pre>
  
  <p>(3) The representation of the items:</p>
  
  <pre><code> public class JNode {
  
      private JsonElement item1 ;
      private JsonElement item2 ;
      //&lt;&gt; more item fields
  
      public JNode() { }
  
      //get &amp; set methods
  
  }
  </code></pre>
  
  <p>Now, creating a Gson instance (<code>FileReader</code> for importing the <code>jsonFile</code>),</p>
  
  <pre><code> Gson gson = new Gson() ;
   JObjectContainer joc = gson.fromJson(jsonFile,JObjectContainer.class) ;
  </code></pre>
  
  <p>I get a <code>NullPointerException</code> whenever I try to access the parseable object (e.g. through a <code>ListIterator</code>). Gson <em>does</em> however create an object of the class I specified and <em>does not</em> throw any subsequent errors.</p>
  
  <p>I know that this has been done before. So, what am I missing?</p>
  
  <p>TIA</p>