这是我的Java代码:
...
HttpResponse response = httpclient.execute(httppost);
HttpEntity responseEntity = response.getEntity();
JSONObject serverResponse = new JSONObject(EntityUtils.toString(responseEntity));
String error = serverResponse.getString("error");
text1.setText(error);
...
我无法解析JSON。
JSON:
[{"error":"1"}]
谢谢!
答案 0 :(得分:2)
您的jsonObject
位于jsonArray
这样做
JSONArray jarray= new JSONArray(EntityUtils.toString(responseEntity));
String error=jarray.getJSONObject(0).getString("error");