net.sf.json.JSONException: Expected a ',' or '}' at character 65 of
net.sf.json.JSONException: Expected a ',' or '}' at character 65 of {"totalCount":343,"data":[{"parkTel":"123456","parkName":"源梦 ?,"parkId":31,"parkAddress":"上海市闵行区虹梅南路215 ?,"parkType":0,"totalParkingSpaces":200,"icons":"http://m3.img.libdd.com/farm5/240/F3B0AF4232D6E2ADFB8DA7B8B624FDF0_250_250.jpg","detailedId":13895,"collect":"2"},{"parkTel":"1521611100","parkName":"恒盛大厦","parkId":32,"parkAddress":"上海市闸北区华盛 ?2 ?,"parkType":0,"totalParkingSpaces在查询的时候出现这个错误,但是这个错误在我的机器上没有出现,放到别人机器上就这样了求解决 --------------------编程问答-------------------- 出现乱码了~倒是json格式出错 --------------------编程问答-------------------- 同楼上,出现乱码了, 导致json格式出错.. --------------------编程问答-------------------- 同上。。。。。 --------------------编程问答-------------------- 大神们,如何解决啊
这是我链接时候的代码:
connection.setDoInput(true);
connection.setDoOutput(true);
PrintWriter out = null;
try {
out = new PrintWriter(connection.getOutputStream());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
out.println(str);
out.close();
// connection.setDoInput(true);
InputStream his = null;
try {
his = connection.getInputStream();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedReader in = new BufferedReader(new InputStreamReader(his));
String s=new String(in.readLine().getBytes(), "UTF-8");
JSONObject json=JSONObject.fromObject(s);
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(json);
return json; --------------------编程问答-------------------- HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url
.openConnection();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
connection.setRequestMethod("POST"); --------------------编程问答-------------------- 求给个解决方案。。。。。。。 --------------------编程问答--------------------
UTF-8是可变长度的编码,原来的字节数组就被改变了。而ISO8859-1通常叫做Latin-1,Latin-1包括了书写所有易做图欧洲语言不可缺少的附加字符,其中 0~127的字符与ASCII码相同,它是单字节的编码方式,这样第二种方式生成的String里的字节数组就跟原来的字节数组一样。在new String使用其他编码如GBK,GB2312的话一样也会导致字节数组发生变化,因此要想获取String里单字节数组,就应该使用iso8859-1编码。
JAVA在网络传输中使用的编码是"ISO-8859-1",故在输出时需要进行转化,如:
String str="中文";
str=new String(str.getBytes("GB2312"),"8859_1"); --------------------编程问答-------------------- 我也遇到过这个问题,这样做就差不多了:
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in,"UTF-8")); --------------------编程问答-------------------- hhb1654605193 正解,解决大问题了
补充:Java , Java EE