How to Prase Response According to the Key.

try {
    JSONArray jsonArray = new JSONArray(response);
    String resultCode = jsonArray.getJSONObject(0).getString("ResultCode");
    if(resultCode.equals("OK"))
    {
        Toast.makeText(this, "Attendance Marked Successfully", Toast.LENGTH_SHORT).show();
    }else if(resultCode.equals("Error"))
    {
        String strErrorMessage = jsonArray.getJSONObject(0).getString("Message");
        Toast.makeText(this, strErrorMessage, Toast.LENGTH_SHORT).show();

    }


}

catch (JSONException e)
{
    e.printStackTrace();
}

Leave a comment