我运行此代码:
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;
}
而responseBody给了我回复:
{"response":{"token":"eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmlJ9","status":"success"}}
如何将“token”作为字符串,“status”
相同答案 0 :(得分:2)
使用此代码。
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();
}
}
});
}
了解详情this answer