這是我的JSON值,如何獲取JSON值給變量?
{"test":"ruslan","status":"OK"}
如何獲得 「測試」 的價值?
這是我HttpClient的代碼存取權限的API
AsyncHttpClient client = new AsyncHttpClient();
client.setBasicAuth("user01", "pwd01");
client.get("http://localhost/web/api/getsession", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
// in this section, I want to store test value from json to a variable
@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
Log.d("Status", "failure");
}
});
1)通過'http://本地主機/網絡/'是行不通2)如果是JSON字符串你的應用?你似乎需要首先將一個byte []轉換爲一個字符串。 –