我得到一個api的httpresponse,但如何從該響應獲取特定的字段?示例返回的響應是這樣的:如何從返回的HttpResponse獲取特定值
{"test": {
"id": 179512,
"name": "Test",
"IconId": 606,
"revisionDate": 139844341200,
"Level": 20
}}
例如,我只想要id字段。
HttpClient client = new DefaultHttpClient();
String getURL = url;
HttpGet get = new HttpGet(getURL);
HttpResponse responseGet = null;
try {
responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
response = EntityUtils.toString(resEntityGet);
Log.e("deneme", response);
return response;
} catch (Exception e) {
e.printStackTrace();
}
我如何能實現GSON以我目前的代碼完成什麼一個非常簡單的例子嗎?我需要將HttpEntity轉換爲Gson嗎?將字符串轉換爲Gson?或者Gson有從我的網址獲取數據的東西? – user3316779