title: Check And Read inner json array which is in main json array in android?
body: <p>I want to check and read a JSON array which is in main JSON array.</p>
  
  <p>How can I check if main jsonarray has a "submenu" array that I want to read?</p>
  
  <p>I implemented my code here but it gives me no value in submenu array:</p>
  
  <pre><code>for (int i = 0; i &lt; jarray.length(); i++) {
    listDataHeader.add(jarray.getJSONObject(i).get(ClassVariable.MENU.TITLE).toString());
  
    // For Getting Main Menu in ArrayList
    String title = jarray.getJSONObject(i).get(ClassVariable.MENU.TITLE).toString();
    String uid = jarray.getJSONObject(i).get(ClassVariable.MENU.UID).toString();
    String pid = jarray.getJSONObject(i).get(ClassVariable.MENU.PID).toString();
  
    HashMap&lt;String,String&gt; map = new HashMap&lt;String, String&gt;();
    map.put(ClassVariable.MENU.TITLE, title);
    map.put(ClassVariable.MENU.UID, uid);
    map.put(ClassVariable.MENU.PID, pid);
    headerarraylist.add(map);
  
    if (jarray.getJSONObject(i).has(ClassVariable.SUBMENU.SUBMENU)) {
      JSONArray jarraysubmenu  = jarray.getJSONObject(i).getJSONArray(ClassVariable.SUBMENU.SUBMENU);
      Log.e("JarraySubmenu","-----&gt;" + jarraysubmenu);
    }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/CZWoD.png" alt="screenshot of sample JSON"></p>