title: How to check JSON object and array
body: <p>I have 2 links; which gives json data. I am trying to get the values from the urls from the same activity in android using asynTask. did the coding till converting the data to string(stored it in <strong>jsonStr1</strong>). But now comes the problem. Because,among the 2 urls: 
  one starts with JSON object- </p>
  
  <pre><code>{    "contacts": [     {"id": "c200", "name": "Ravi Tamada"  },
  
                         { "id": "c201", "name": "Johnny Depp" }
                  ]
   }
  </code></pre>
  
  <p>another start with JSON array-</p>
  
  <pre><code> [{"appeId":"1","survId":"1"}, 
     {"appeId":"2","survId":"32"}
    ]
  </code></pre>
  
  <p>Now how am i going to give a condition for them whether to know its a JSON array or Object? JSON array are object that i know but cant find how to separate them. i have tried the below:</p>
  
  <pre><code>JSONObject jsonObj = new JSONObject(jsonStr1);
     if(jsonObj instanceof JSONArray){}
  </code></pre>
  
  <p>but if condition is showing error- <em>incompatible  conditional operand types JSONObject and JSONArray</em></p>