title: How to remove empty objects from Json Array
body: <p>So the json is something like it,</p>
  
  <pre><code>"stores": [
  {
  "amazon": []
  },
  {
  "flipkart": {
  "product_store": "Flipkart",
  "product_store_logo": "http://images-api.datayuge.in/image/ZmxpcGthcnRfc3RvcmUucG5n.png",
  "product_store_url": "https://price-api.datayuge.com/redirect?id=aHR0cHM6Ly9kbC5mbGlwa2FydC5jb20vZGwvbWktYTEtYmxhY2stNjQtZ2IvcC9pdG1leDl3eHh6M2FtamF0P3BpZD1NT0JFWDlXWFVTWlZZSEVUJmFmZmlkPWFydW5iYWJ1bA",
  "product_price": "14999",
  "product_offer": "",
  "product_color": "",
  "product_delivery": "3-4",
  "product_delivery_cost": "0",
  "is_emi": "1",
  "is_cod": "1",
  "return_time": "10 Days"
  }
  },
  {
  "snapdeal": []
  }
  ]
  </code></pre>
  
  <p>So the non empty object like flipkart is a JsonObject but all other empty objects are array. So I am so confused about how to remove them.</p>
  
  <pre><code>JSONArray store_array = product_details_json.getJSONObject("data").getJSONArray("stores");
                      for (int i = 0; i&lt;store_array.length(); i++){
                          JSONObject store = store_array.getJSONObject(i);
  
                          if (!store.getJSONObject(store.keys().next()).has("product_store")){
                              store_array.remove(i);
                          }else {
                              Log.i("Size :",store_array.length()+"");
  
                          }
                      }
  </code></pre>
  
  <p>But that's not working. I know I am doing this all wrong. Because it has both array and objects so i get the following error</p>
  
  <pre><code>Value [] at amazon of type org.json.JSONArray cannot be converted to JSONObject
  </code></pre>
  
  <p>Need Help!</p>