新浪JAVA API返回的JSON数据里面中文乱码
我用了一个checkinsList函数获取用户签到列表,返回的JSON数据是:{"pois":[{"poiid":"B2094654D16CABFE419E","titl...
我用了一个checkinsList 函数获取用户签到列表,返回的JSON数据是:
{"pois":[{"poiid":"B2094654D16CABFE419E","title":"\u7406\u60f3\u56fd\u9645\u5927\u53a6","address":"\u6d77\u6dc0\u4e2d\u5173\u6751\u9ad8\u79d1\u6280\u5e7f\u573a2\u53f7,\u5317\u56db\u73af\u897f\u8def58\u53f7\u7406\u60f3\u56fd\u9645\u5927\u53a6","lon":"116.30985600813392","lat":"39.98436711624586","category":"46","city":"0010","province":"11","country":"80086","url":"","phone":"010-c":"http:\/\/ww1.sinaimg.cn\/wap180\/4e704b16jw1e9trdre01yj205005074c.jpg","pintu":1,"poi_street_address":"\u5317\u4eac\u5e02,\u6d77\u6dc0\u533a,\u6d77\u6dc0\u897f\u8857","poi_street_summary":"\u6d77\u6dc0\u4e2d\u5173\u6751\u9ad8\u79d1\u6280\u5e7f\u573a2\u53f7,\u5317\u56db\u73af\u897f\u8def58\u53f7\u7406\u60f3\u56fd\u9645\u5927\u53a6","enterprise":0,"checkin_time":"2014-08-14 15:42:23"},],"total_number":"348"} 中文变成"\u7406\u60f3\u56fd\u9645\u5927\u53a6", 如何把这乱码解决啊????? 展开
{"pois":[{"poiid":"B2094654D16CABFE419E","title":"\u7406\u60f3\u56fd\u9645\u5927\u53a6","address":"\u6d77\u6dc0\u4e2d\u5173\u6751\u9ad8\u79d1\u6280\u5e7f\u573a2\u53f7,\u5317\u56db\u73af\u897f\u8def58\u53f7\u7406\u60f3\u56fd\u9645\u5927\u53a6","lon":"116.30985600813392","lat":"39.98436711624586","category":"46","city":"0010","province":"11","country":"80086","url":"","phone":"010-c":"http:\/\/ww1.sinaimg.cn\/wap180\/4e704b16jw1e9trdre01yj205005074c.jpg","pintu":1,"poi_street_address":"\u5317\u4eac\u5e02,\u6d77\u6dc0\u533a,\u6d77\u6dc0\u897f\u8857","poi_street_summary":"\u6d77\u6dc0\u4e2d\u5173\u6751\u9ad8\u79d1\u6280\u5e7f\u573a2\u53f7,\u5317\u56db\u73af\u897f\u8def58\u53f7\u7406\u60f3\u56fd\u9645\u5927\u53a6","enterprise":0,"checkin_time":"2014-08-14 15:42:23"},],"total_number":"348"} 中文变成"\u7406\u60f3\u56fd\u9645\u5927\u53a6", 如何把这乱码解决啊????? 展开
3个回答
推荐于2016-07-05 · 知道合伙人软件行家
关注
展开全部
这是unicode编码,不是乱码,你进行Unicode转码就出来了
给你写个方法转码,将unicode传递进去返回字符串
public String convert(String utfString){
StringBuilder sb = new StringBuilder();
int i = -1;
int pos = 0;
while((i=utfString.indexOf("\\u", pos)) != -1){
sb.append(utfString.substring(pos, i));
if(i+5 < utfString.length()){
pos = i+6;
sb.append((char)Integer.parseInt(utfString.substring(i+2, i+6), 16));
}
}
return sb.toString();
}
展开全部
这个不是乱码,是unicode编码,需要转成GBK或者GB2312之类的。你百度一下java如何处理unicode就可以了哈~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这里面返回的是unicode编码 返回值加上强制类型转换试试吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询