-3
 HttpResponse httpResponse = httpClient.execute(httpGet);

I am getting this response in json format.the data I receive is

 {"message":"Successful","token":"123456"}.

now I want to parse it if the message is successful then I want to print successful login.My question is how to do this.

User12111111
  • 1,179
  • 1
  • 19
  • 41

1 Answers1

0

Try this

String msg = "{'message':'Successful','token':'123456'}";

    JSONObject obj;
    try {
        obj = new JSONObject(msg);

        if (obj.has("message")
                && obj.getString("message").equals("Successful")) {
            if (obj.has("token")) {
                Log.i("token", obj.getString("token") + " token");
            }
        }

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Shini
  • 573
  • 4
  • 11