title: JSON Java check element is a JSONArray or JSONObject
body: <p>How to check whether an element is a JSONArray or JSONObject. I wrote the code to check, </p>
  
  <pre><code>if(jsonObject.getJSONObject("Category").getClass().isArray()) {
  
  } else {
  
  }
  </code></pre>
  
  <p>In this case if the element 'category' is JSONObject then it work fine but if it contains an array then it throw exception: JSONArray cannot be converted to JSONObject. Please help.
  Thanks.</p>