【发布时间】:2014-11-13 13:36:21
【问题描述】:
我正在尝试通过https://www.cyb3rpirat3s.in/android/leaderboard.php 网站以 json 的形式获取大量数据..但问题是从上面的链接获取一些数据后,logcat 出现无法解析 json 的错误(由于不完整获取 json)。我是 android 新手,不知道我应该如何处理大量的 json。我什至已经为它搜索过,但无法找到相关信息。 提前致谢
public JSONObject makeHttpRequest(String url, List<NameValuePair> params) {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
int status=httpResponse.getStatusLine().getStatusCode();
if(status==200){
HttpEntity httpEntity = httpResponse.getEntity();
String data=EntityUtils.toString(httpEntity);
json=data.split("<!--")[0];
Log.d("sdjb",json);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
jObj = new JSONObject(json);
Log.d("sf",jObj.getString("success"));
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jObj;
}
logcat 错误:
11-13 19:03:22.873: E/JSON Parser(7979): 解析数据时出错 org.json.JSONException: Value [{"rank":1,"1":"11","level": "11","0":"the_godfather","piratename":"the_godfather"},{"rank":2,"1":"6","level":"6","0":"ShiniGami ","piratename":"ShiniGami"},{"rank":3,"1":"6","level":"6","0":"hurricane","piratename":"hurricane"} ,{"rank":4,"1":"6","level":"6","0":"the_batman","piratename":"the_batman"},{"rank":5,"1 ":"6","level":"6","0":"the_boatswain","piratename":"the_boatswain"},{"rank":6,"1":"5","level": "5","0":"battlemonger","piratename":"battlemonger"},{"rank":7,"1":"5","level":"5","0":"MishuAnubis ","piratename":"MishuAnubis"},{"rank":8,"1":"5","level":"5","0":"YogeshPatil","piratename":"YogeshPatil"} ,{“排名”:
【问题讨论】:
-
对不起我的错误......