Android JSON解析不会获取完整的字符串
如果JSON字符串非常大,我会看到一个问题,因为它不能获取所有内容 因此,我有一个基于流行示例的JSONparsing类:Android JSON解析不会获取完整的字符串,android,json,androidhttpclient,android-json,Android,Json,Androidhttpclient,Android Json,如果JSON字符串非常大,我会看到一个问题,因为它不能获取所有内容 因此,我有一个基于流行示例的JSONparsing类: public String makeServiceCall(String url, int method, List<NameValuePair> params) { try { // http client DefaultHttpClient httpClient = new DefaultHttpCli
public String makeServiceCall(String url, int method,
List<NameValuePair> params) {
try {
// http client
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
// Checking http request method type
if (method == POST) {
HttpPost httpPost = new HttpPost(url);
// adding post params
if (params != null) {
httpPost.setEntity(new UrlEncodedFormEntity(params));
}
httpResponse = httpClient.execute(httpPost);
} else if (method == GET) {
// appending params to url
if (params != null) {
String paramString = URLEncodedUtils
.format(params, "utf-8");
url += "?" + paramString;
}
HttpGet httpGet = new HttpGet(url);
httpResponse = httpClient.execute(httpGet);
}
httpEntity = httpResponse.getEntity();
if (httpEntity != null) {
try {
response= new String(EntityUtils.toString(httpEntity));
Log.d(TAG, response);
}
catch (ParseException exc) {
// TODO Auto-generated catch block
exc.printStackTrace();
} catch (IllegalStateException exc) {
// TODO Auto-generated catch block
exc.printStackTrace();
}
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return response;
}
返回不完整的字符串。
如果我将JSON字符串变小,那么就可以了
有人知道我必须做什么才能得到实体吗?除非我把所有东西都还给我,或者给它一个更大的缓冲区
谢谢你是使用GET还是POST?为什么不使用截击?这会让你的生活更轻松。我正在使用GET请求
response= new String(EntityUtils.toString(httpEntity));