title: How to check whether the given object is object or Array in JSON string
body: <p>I am getting JSON string from website. I have data which looks like this (JSON Array)</p>
  
  <pre><code> myconf= {URL:[blah,blah]}
  </code></pre>
  
  <p>but some times this data can be (JSON object)</p>
  
  <pre><code> myconf= {URL:{try}}
  </code></pre>
  
  <p>also it can be empty</p>
  
  <pre><code> myconf= {}    
  </code></pre>
  
  <p>I want to do different operations when its object and different when its an array. Till now in my code I was trying to consider only arrays so I am getting following exception. But I am not able to check for objects or arrays.</p>
  
  <p>I am getting following exception</p>
  
  <pre><code>    org.json.JSONException: JSONObject["URL"] is not a JSONArray.
  </code></pre>
  
  <p>Can anyone suggest how it can be fixed. Here I know that objects and arrays are the instances of the JSON object. But I couldn't find a function with which I can check whether the given instance is a array or object.</p>
  
  <p>I have tried using this if condition but with no success</p>
  
  <pre><code>if ( myconf.length() == 0 ||myconf.has("URL")!=true||myconf.getJSONArray("URL").length()==0)
  </code></pre>