[Solved] How to parse this type of json array in android?

Try this. try { JSONObject jsonObject = new JSONObject(“JSONResponse”); String scode = jsonObject.optString(“scode”); JSONArray allmenuArray = jsonObject.optJSONArray(“all_menu”); for (int i = 0; i < allmenuArray.length(); i++) { JSONObject objectJson = allmenuArray.optJSONObject(i); boolean sub_menu = objectJson.getBoolean(“sub_menu”); String app_menu_id = objectJson.getString(“app_menu_id”); String app_menu_name = objectJson.getString(“app_menu_name”); JSONArray all_sub_menu = objectJson.getJSONArray(“all_sub_menu”); for (int j = 0; j < all_sub_menu.length(); … Read more

[Solved] org.json.JSONObject$1 cannot be converted to JSONObject error while parsing json string

After reading JsonArray and JsonObject doc i understand how to sort out this problem. protected void parseJson() { JSONObject object=null; try { object=new JSONObject(json); myArray=object.getJSONArray(MY_ARRAY); Log.e(“Array Length”,””+myArray.length()); key_id=new String[myArray.length()]; key_name=new String[myArray.length()]; for (int i=0;i<=myArray.length();i++) { JSONObject fetchObject=myArray.optJSONObject(i); if(fetchObject==null) { //do nothing } else { key_id[i] = fetchObject.getString(KEY_ID); key_name[i] = fetchObject.getString(KEY_NAME); } } } catch (JSONException … Read more