Question

This is my codes:

                    BufferedReader reader = new BufferedReader(new InputStreamReader(
                            inputStreamObjectValue));

                    StringBuilder sb = new StringBuilder();
                    String line = null;
                    // Read Server Response
                    while ((line = reader.readLine()) != null) {
                        // Append server response in string
                        sb.append(line + "\n");

                    }
                    Log.e("values :",sb.toString());

When i run then Log print

{"Status":1,"SessionId":"ulrvmysxrmha14t0cd031upp6yluh69amgfub02j78lubcht5i"}

How to separate item.Such as

Status=1 and SessionId="ulrvmysxrmha14t0cd031upp6yluh69amgfub02j78lubcht5i";

Please help me.

Was it helpful?

Solution

Use this:

try {
    JSONObject job = new JSONObject(sb.toString());
    int Status = job.getInt("Status");
    String SessionId = job.getString("SessionId");
} catch (JSONException e) {
    // Handle error
}

Reference: http://developer.android.com/reference/org/json/JSONObject.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top