我会解析 JSON
public JSONObject getJSONFromUrl() {
try {
DefaultHttpClient httpClient = getNewHttpClient();
String auth = android.util.Base64.encodeToString(
("estafeta@62e12548-0a68-4999-960b-a3bb3c44675c:11111")
.getBytes("UTF-8"), android.util.Base64.NO_WRAP);
HttpGet get = new HttpGet(
"https://test2.estafeta.org/mobileestafeta/MobileSurveyReportsService.svc/LoadTabletSurveyTasks?startRowVersion=AAAAAAAAAAA=&count=500");
get.addHeader("Authorization", "Basic " + auth);
HttpResponse httpResponse = httpClient.execute(get);
//httpResponse.getStatusLine().getStatusCode()
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jObj;
}
我从服务器下载了 Json 但不知道它的大小和结构
1)告诉我如何查看从服务器收到的 JSON 的大小和结构?
2) 如何查看 jObj 的内容?
3)会发生什么,为什么有这么多行?