title: How to check if JSONArray Element is null
body: <p>I can't figure out how to determine is an element that lives inside a json array is null. To check if the jsonObject itself is null, you simply use:</p>
  
  <pre><code>jsonObject.isNullObject();
  </code></pre>
  
  <p>But when the object is an array and I want to check if one of the elements of that array is null, this does not work:</p>
  
  <pre><code>jsonArray.get(i).get("valueThatIsNull") == null;
  </code></pre>
  
  <p>There is also no isNull method available on elements of an array. How do I check if values inside a jsonarray are null? It might help to know that I am passing over a null object from javascript. Maybe null does not mean the same thing in java when it is passed from javascript in json format, but I have also tried putting parentheses around the null and it still does not work.</p>
  
  <p>I am posting some actual source code to help make this clearer. The jsonObject is a part of the jsonArray and the object has multiple values because it iself is an object.</p>
  
  <pre><code>JSONObject mapItem = jsonArray.getJSONObject(i);
  int id = mapItem.has("id") ? mapItem.getInt("id") : -1;
  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  java.util.Date date = null;
  Date sqlDate = null;
  if(mapItem.has("date")) {
      String dateStr = mapItem.getString("date");
      if(!dateStr.equals("null")) {
      date = dateFormat.parse(mapItem.getString("date").substring(0, 10)); //Convert javascript date string to java.
      sqlDate = new Date(date.getTime());
  }
  </code></pre>