-1

Following is the string. help to get this.

Thank you advance...!

OUTPUT

{

    "status" : 0,
    "message" : payment status for :111189,
    "result" : -{
        "postBackParamId" : 1321,
        "mihpayid" : 4039937155186,
        "paymentId" : 11117,
        "mode" : CC,
        "status" : failure,
        "unmappedstatus" : failed
    }

}
Wasim K. Memon
  • 5,979
  • 4
  • 40
  • 55
prasanna
  • 3
  • 2
  • Possible duplicate of [Sending and Parsing JSON Objects in Android](https://stackoverflow.com/questions/2818697/sending-and-parsing-json-objects-in-android) – Rahul Khurana Nov 30 '18 at 05:55
  • You may test the JSON in jsonlint.com to confirm, if it is parse-able json. Then you may try coding to parse it. – SHS Nov 30 '18 at 06:38
  • .your JSON is invalid. You obviously can't parse invalid JSON – Vladyslav Matviienko Nov 30 '18 at 06:41
  • JSON is valid @VladyslavMatviienko – prasanna Nov 30 '18 at 07:47
  • Any JSON validator will say that you are wrong. For example, JSOn values have to be put in double quotes, unless it is a number, or null. in your JSON `"message" : payment status for :111189` value is not in quotes. Already invalid. – Vladyslav Matviienko Nov 30 '18 at 08:17

2 Answers2

2
            JSONObject jsonObject = new JSONObject( JSON_response );
            int status = jsonObject.getInt("status");
            String message = jsonObject.getString("message");
            String result = jsonObject.getString("result");
            JSONObject jsonObject1 = new JSONObject( result );
            int postBackParamId = jsonObject1.getInt("postBackParamId");
            String mihpayid = jsonObject1.getString("mihpayid");
            int paymentId = jsonObject1.getInt("paymentId");
            String mode = jsonObject1.getString("mode");
            String result_status = jsonObject1.getString("status");
            String unmappedstatus = jsonObject1.getString("unmappedstatus");
Unnati Patadia
  • 662
  • 3
  • 19
  • 39
0
public class ApiResponse {

    public Integer status;

    public String message;

    public Result result;

}

public class Result {

    public Integer postBackParamId;

    public String mihpayid;

    public Integer paymentId;

    public String mode;

    public String status;

    public String unmappedstatus;
}

Pass class ApiResponse while hitting web service using any library like Retrofit and then in on success you can get the value like: -

response.result.postBackParamId (response object in on success).
Wasim K. Memon
  • 5,979
  • 4
  • 40
  • 55
Anita
  • 39
  • 1
  • 7