(1) :
org.json.JSONException: Expected a ',' or '}' at 80 [character 81 line 1]
原因:出现乱码了, 导致json格式出错..
解决方法:
String result = new String(data,"utf-8");
默认是iso8859-1
(将编码方式改为utf-8)
if(response.getStatusLine().getStatusCode()==200){
HttpEntity httpEntity = response.getEntity();
byte[] data = EntityUtils.toByteArray(httpEntity);
String result = new String(data,"utf-8");
jsoncCallBack.response(result);
}
(2) :
java.lang.IllegalArgumentException: Malformed escape pair at index 86: http://sns.maimaicha.com/api?apikey=b4f4ee31a8b9acc866ef2afb754c33e6&format=json&page=%d&rows=20&method=news.getListByType&type=16
at java.net.URI.create(Unknown Source)
at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:69)
at http.HttpUtils.downloadData(HttpUtils.java:37)
at test.Test2.main(Test2.java:31)
Caused by: java.net.URISyntaxException: Malformed escape pair at index 86: http://sns.maimaicha.com/api?apikey=b4f4ee31a8b9acc866ef2afb754c33e6&format=json&page=%d&rows=20&method=news.getListByType&type=16
原因:URL语法异常
&format=json&page=%d
解决方法:
这里这个 后面%d 应该改为数字(例如1 。。。)
|