0

I am getting error in the food delivery app while placing an order

public void resultAlert(String HasilProses) {
        Log.e("HasilProses", HasilProses);

        
        try {
            JSONObject jsonObject = new JSONObject(HasilProses);

            JSONArray jsonArray = jsonObject.getJSONArray("ORDER_PLACED");

            for (int i = 0; i < jsonArray.length(); i++) {

                JSONObject object = jsonArray.getJSONObject(i);
                String error = object.getString("error");
                int order_id = Integer.parseInt(object.getString("order_id"));
                Constant_Api.order_id = order_id;
                String message = object.getString("message");

                
                dbhelper.deleteAllData();
                if (payable>0) {
                    startPayment();
                }
                else{
                    lytOrder.setVisibility(View.GONE);
                    txtAlert.setVisibility(View.GONE);
                    recyclerView.setVisibility(View.GONE);
                    paymentUpdate("0");
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

my Logcat error and JSON response

 Failed{
    "ORDER_PLACED": [
        {
            "error": "true",
            "message": "Failed"
        }
    ]
}

W/System.err: org.json.JSONException: Value Failed of type java.lang.String cannot be converted to JSONObject

W/System.err: at org.json.JSON.typeMismatch(JSON.java:112) at org.json.JSONObject.(JSONObject.java:168)

W/System.err: at org.json.JSONObject.(JSONObject.java:181)

Machavity
  • 30,841
  • 27
  • 92
  • 100

0 Answers0