在这里,我试图从 URL 获取 Json 数据。但是 oit 只显示部分数据。以下是我如何读取数据的详细信息
BufferedInputStream 是;
HttpGet httpGet = new HttpGet(url);
httpGet.addHeader("Accept", "application/json");
HttpResponse httpResponse = getHttpClient().execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = new BufferedInputStream(httpEntity.getContent()) ;
public void getJsonwithByteArray(BufferedInputStream istream) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int ctr;
try {
ctr = istream.read();
while (ctr != -1) {
byteArrayOutputStream.write(ctr);
ctr = istream.read();
}
istream.close();
} catch (IOException e) {
e.printStackTrace();
}
Log.v("Text Data", byteArrayOutputStream.toString());
try {
// Parse the data into jsonobject to get original data in form of
// json.
JSONObject jObject = new JSONObject(
byteArrayOutputStream.toString());
jObj = jObject;
Log.v("JsonParser", "JsonByteArry data: " + jObj.toString());
} catch (Exception e) {
e.printStackTrace();
}
}