Reputation: 175
I run this code :
protected Object doInBackground(Object[] objects) {
HttpClient client = new HttpClient();
client.get(get_token, new HttpResponseCallback() {
@Override
public void success(String responseBody) {
runOnUiThread(new Runnable() {
@Override
public void run() {
llHolder.setVisibility(View.VISIBLE);
}
});
token = responseBody;
}
And the responseBody gives me back :
{"response":{"token":"eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmlJ9","status":"success"}}
How do I get "token" as a string , same for "status"
Upvotes: 0
Views: 44
Reputation: 76912
Use this code.
protected Object doInBackground(Object[] objects) {
HttpClient client = new HttpClient();
client.get(get_token, new HttpResponseCallback() {
@Override
public void success(String responseBody) {
runOnUiThread(new Runnable() {
@Override
public void run() {
llHolder.setVisibility(View.VISIBLE);
try {
JSONObject jObject = new JSONObject(responseBody);
String token = jObject.getString("token");
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
for more info look this answer
Upvotes: 2