title: How to test if a JSONObject is null or doesn't exist
body: <p>I have a set of <code>JSONObject</code> values which i receive from a server and operate on. Most times I get a <code>JSONObject</code> with a value (let's say statistics) and sometimes, it returns an <code>Error</code> object with a code and a description of the error.</p>
  
  <p>How do I structure my code so that it doesn't break if it returns the error. I thought I could do this, but doesn't work.</p>
  
  <pre><code>public void processResult(JSONObject result) {
      try {
          if(result.getJSONObject(ERROR) != null ){
              JSONObject error = result.getJSONObject(ERROR);
              String error_detail = error.getString(DESCRIPTION);
              if(!error_detail.equals(null)) {
                  //show error login here
              }
              finish();
          }
          else {
              JSONObject info = result.getJSONObject(STATISTICS);
              String stats = info.getString("production Stats"));
          }
      }
  }
  </code></pre>