【发布时间】:2011-07-28 12:31:35
【问题描述】:
在我的应用程序中,我需要从服务器获取一些数据。在 Eclipse 中,我收到这样的数据:
[{"id_category":"1","category_name":"Cool"},{"id_category":"2","category_name":"Glamor"},{"id_category":"3","category_name":"Funky"},{"id_category":"4","category_name":"Crazy"},{"id_category":"5","category_name":"David Guetta"}] 没有任何名字。
我试过这样的:
if (response != null) {
responseBody = EntityUtils.toString(response.getEntity());
System.out
.println("Rezultat de la server pentru a afla categoriile:"
+ responseBody);
try {
final String r = response.toString();
String name = json.getString("category name");
System.out.println("One category"+name);
} catch (JSONException e) {
// do nothing
} catch (FacebookError e) {
e.getMessage();
}
但什么也没发生。如何从我的回复中获得id_category 和category_name?
谁能帮我?提前致谢。
【问题讨论】: