title: Why does my JSON-Simple JSONArray give me a nullpointer exception?
body: <p>I'm following this tutuorial <a href="http://www.mkyong.com/java/json-simple-example-read-and-write-json/" rel="nofollow">here</a>, and my JSON object is near enough the same, except I have this sort of format:</p>
  
  <pre><code>{"user":{
      "SomeKeys":"SomeValues",
      "SomeList":["val1","val2"]
      }
  }
  </code></pre>
  
  <p>Here is my relevant code:</p>
  
  <pre><code>Object obj = parser.parse(new FileReader("exampleJson.json"));
  
  JSONObject jsonObject = (JSONObject) obj;
  JSONObject user = (JSONObject) jsonObject.get("user");
  JSONArray list = (JSONArray) user.get("SomeList");
  </code></pre>
  
  <p>Then my program goes off an gets the values form the keys etc. Or it would but I get a <code>NullPointerException</code> from eclipse. <em>Why is this?</em></p>
  
  <p>It should unpackage my <code>.json</code> file into <code>jsonObject</code>, unpackage the "user" key as a JSONObject <code>user</code>, then unpackage the "SomeList" key as a JSONArray called <code>list</code>. Except when it does so it must be trying to put one of <code>val1</code> or <code>val2</code> into a part of the JSONArray that does not exist and just points into the abyss of <code>null</code>. <em>What have I done <strike>to deserve this</strike> wrong ?</em></p>
  
  <p><strong>How do I fix my program?</strong></p>