about json array i have doble array and object

this is the code need jsonArray and jsonArray2 how to see in php subcategory and products

need like this query

{"subcategory":null,"products":null}

but i have

{"subcategory":[{"id":"6","name":"Test For use"}],"products":[{"id":"6","name":"Erazole 20 Teblet","image":"http://sub.dayeepharma.com/Android/android_login_api/productphoto/Regular.jpg","price":"251","our_price":"250","catid":"2"}]}


  private void processJsonObject2(JSONObject response) {
    if (response != null) {
        Log.e("==RESPONSE ERROR=", response.toString());
        try {
            JSONArray jsonArray = response.getJSONArray("subcategory");
            ArrayList<SubCategoryPojo> arrayList=new ArrayList<SubCategoryPojo>();
            for (int i=0; i<jsonArray.length(); i++){
                JSONObject jsonObject=jsonArray.getJSONObject(i);

                SubCategoryPojo subCategoryPojo=new SubCategoryPojo();
                subCategoryPojo.setId(jsonObject.getString("id"));
                subCategoryPojo.setName(jsonObject.getString("name"));
                Log.e("JSON TEST",jsonObject.getString("id"));
                arrayList.add(subCategoryPojo);
            }
            JSONArray jsonArray2 = response.getJSONArray("products");
            productPojoArrayList=new ArrayList<ProductPojo>();
            for (int i=0; i<jsonArray2.length(); i++){
                JSONObject jsonObject=jsonArray2.getJSONObject(i);

                ProductPojo productPojo=new ProductPojo();
                productPojo.setId(jsonObject.getString("id"));
                productPojo.setName(jsonObject.getString("name"));
                productPojo.setImage(jsonObject.getString("image"));
                productPojo.setPrice(jsonObject.getString("price"));
             productPojo.setOurprice(jsonObject.getString("our_price"));
                Log.e("JSON TEST",jsonObject.getString("id"));
                productPojoArrayList.add(productPojo);
            }
           SubcategoriesAdapter adapter = new SubcategoriesAdapter(arrayList);
            productsAdapter=new ProductsAdapter(getApplicationContext(),productPojoArrayList);
            vertical_recycler_view.setAdapter(productsAdapter);
            horizontal_recycler_view.setAdapter(adapter);
        }catch (Exception e){

        }

    }
}

Try this .

private void processJsonObject2(JSONObject response) {
    if (response != null) {
        Log.e("==RESPONSE ERROR=", response.toString());
        try {
            JSONArray jsonArray = response.getJSONArray("subcategory");
            // edited here ,add judgement
            if(jsonArray.length() != 0 &&jsonArray != null){
                ArrayList<SubCategoryPojo> arrayList = new ArrayList<SubCategoryPojo>();
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonObject = jsonArray.getJSONObject(i);

                    SubCategoryPojo subCategoryPojo = new SubCategoryPojo();
                    subCategoryPojo.setId(jsonObject.getString("id"));
                    subCategoryPojo.setName(jsonObject.getString("name"));
                    Log.e("JSON TEST", jsonObject.getString("id"));
                    arrayList.add(subCategoryPojo);
                }
            } else {
                Toast.makeText(this, "subcategory is null", Toast.LENGTH_SHORT).show();
            }


            JSONArray jsonArray2 = response.getJSONArray("products");
            // edited here ,add judgement
            if(jsonArray.length() != 0 &&jsonArray != null){
                productPojoArrayList = new ArrayList<ProductPojo>();
                for (int i = 0; i < jsonArray2.length(); i++) {
                    JSONObject jsonObject = jsonArray2.getJSONObject(i);

                    ProductPojo productPojo = new ProductPojo();
                    productPojo.setId(jsonObject.getString("id"));
                    productPojo.setName(jsonObject.getString("name"));
                    productPojo.setImage(jsonObject.getString("image"));
                    productPojo.setPrice(jsonObject.getString("price"));
                    productPojo.setOurprice(jsonObject.getString("our_price"));
                    Log.e("JSON TEST", jsonObject.getString("id"));
                    productPojoArrayList.add(productPojo);
                }
            } else {
                Toast.makeText(this, "products is null", Toast.LENGTH_SHORT).show();
            }

            SubcategoriesAdapter adapter = new SubcategoriesAdapter(arrayList);
            productsAdapter = new ProductsAdapter(getApplicationContext(), productPojoArrayList);
            vertical_recycler_view.setAdapter(productsAdapter);
            horizontal_recycler_view.setAdapter(adapter);
        } catch (Exception e) {

        }
    }
}

Add if(jsonArray.length() != 0 &&jsonArray != null){} in your code .