求数据解析

jgszhuzhu 2012-08-27 02:35:57
数据如下
{"total":79,"total_hot":24,"errorMsg":"","citys":{"A":{"101115105":"\u5b89\u9633"},"B":{"101101":"\u5317\u4eac"},"C":{"101104":"\u91cd\u5e86\u5e02","101108108":"\u627f\u5fb7","101117107":"\u5e38\u5fb7","101117101":"\u957f\u6c99","101123101":"\u6210\u90fd\t\t"},"D":{"101123115":"\u8fbe\u5dde","101101101":"\u4e1c\u57ce\u533a"},"F":{"101119101":"\u798f\u5dde"},"G":{"101124101":"\u8d35\u9633","101120101":"\u5e7f\u5dde"},"H":{"101115106":"\u9e64\u58c1","101117112":"\u6000\u5316","101114101":"\u5408\u80a5","101122101":"\u6d77\u53e3\t\t"},"J":{"101112104":"\u5609\u5174","101115108":"\u7126\u4f5c","101118104":"\u4e5d\u6c5f","101113101":"\u6d4e\u5357\t\t"},"K":{"101125101":"\u6606\u660e","101115102":"\u5f00\u5c01"},"L":{"101108110":"\u5eca\u574a","101115103":"\u6d1b\u9633","101115111":"\u6f2f\u6cb3","101121102":"\u67f3\u5dde","101117113":"\u5a04\u5e95"},"M":{"101120112":"\u6885\u5dde","101123106":"\u7ef5\u9633"},"N":{"101112102":"\u5b81\u6ce2","101111101":"\u5357\u4eac","101115113":"\u5357\u9633","101118101":"\u5357\u660c\t\t","101121101":"\u5357\u5b81"},"P":{"101115104":"\u5e73\u9876\u5c71","101115109":"\u6fee\u9633"},"Q":{"101113102":"\u9752\u5c9b","101120116":"\u6e05\u8fdc"},"S":{"101120103":"\u6df1\u5733","101102":"\u4e0a\u6d77\t\t","101108101":"\u77f3\u5bb6\u5e84\t\t","101111105":"\u82cf\u5dde","101116103":"\u5341\u5830","101115114":"\u5546\u4e18","101117105":"\u90b5\u9633","101112106":"\u7ecd\u5174"},"T":{"101103":"\u5929\u6d25","101108102":"\u5510\u5c71","101109101":"\u592a\u539f\t\t","101112110":"\u53f0\u5dde"},"W":{"101112103":"\u6e29\u5dde","101111102":"\u65e0\u9521","101116101":"\u6b66\u6c49","101104101":"\u4e07\u5dde"},"X":{"101130101":"\u897f\u5b81","101119102":"\u53a6\u95e8","101117103":"\u6e58\u6f6d","101111103":"\u5f90\u5dde","101115107":"\u65b0\u4e61","101115115":"\u4fe1\u9633","101115110":"\u8bb8\u660c","101116105":"\u8944\u9633","101116108":"\u5b5d\u611f","101127101":"\u897f\u5b89\t\t","101115101111":"\u65b0\u90d1"},"Y":{"101121109":"\u7389\u6797","101116104":"\u5b9c\u660c","101117106":"\u5cb3\u9633","101117109":"\u76ca\u9633","101117111":"\u6c38\u5dde","101129101":"\u94f6\u5ddd\t\t"},"Z":{"101115116":"\u5468\u53e3","101117102":"\u682a\u6d32","101120104":"\u73e0\u6d77","101117108":"\u5f20\u5bb6\u754c","101124103":"\u9075\u4e49","101115117":"\u9a7b\u9a6c\u5e97","101120101111":"\u589e\u57ce","101115101":"\u90d1\u5dde"}},"hotcitys":{"\u70ed\u95e8\u57ce\u5e02":{"101101":"\u5317\u4eac","101115101":"\u90d1\u5dde","101120103":"\u6df1\u5733","101102":"\u4e0a\u6d77","101111101":"\u5357\u4eac","101114101":"\u5408\u80a5","101125101":"\u6606\u660e","101118101":"\u5357\u660c","101108101":"\u77f3\u5bb6\u5e84","101116101":"\u6b66\u6c49","101117101":"\u957f\u6c99","101123101":"\u6210\u90fd","101104":"\u91cd\u5e86","101127101":"\u897f\u5b89","101105101":"\u54c8\u5c14\u6ee8","101107101":"\u6c88\u9633","101113102":"\u9752\u5c9b","101119101":"\u798f\u5dde","101109101":"\u592a\u539f","101120101":"\u5e7f\u5dde","101113101":"\u6d4e\u5357","101121101":"\u5357\u5b81","101122101":"\u6d77\u53e3","101103":"\u5929\u6d25"}}}
...全文
199 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jgszhuzhu 2012-08-27
  • 打赏
  • 举报
回复
这种都太麻烦了,请看
public class SelectCityBean {
public String total;
public String total_hot;

public LinkedHashMap<String, HashMap<String, String>> citys;
public LinkedHashMap<String, HashMap<String, String>> hotcitys;

public String getTotal() {
return total;
}

public void setTotal(String total) {
this.total = total;
}

public String getTotal_hot() {
return total_hot;
}

public void setTotal_hot(String total_hot) {
this.total_hot = total_hot;
}

public LinkedHashMap<String, HashMap<String, String>> getCitys() {
return citys;
}

public void setCitys(LinkedHashMap<String, HashMap<String, String>> citys) {
this.citys = citys;
}

public LinkedHashMap<String, HashMap<String, String>> getHotcitys() {
return hotcitys;
}

public void setHotcitys(
LinkedHashMap<String, HashMap<String, String>> hotcitys) {
this.hotcitys = hotcitys;
}

}



在第二个类中解析
//GSON数据解析
public List<SelectCityBean> JsonParse(String string) {
List<SelectCityBean> list = new ArrayList<SelectCityBean>();
Gson gson = new Gson();
SelectCityBean s = gson.fromJson(string, SelectCityBean.class);
list.add(s);

return list;
}
franzhong 2012-08-27
  • 打赏
  • 举报
回复

String JSONString = "{'myMain':{'total':79,'total_hot':24,'errorMsg':'testtest','citys':{'A':{'AAAA':'BBBB'},'B':{'CCCC':'DDDD'}}}}";
JSONObject jsonObject = new JSONObject(JSONString).getJSONObject("myMain");
Log.i(MYLOG,jsonObject.getString("errorMsg"));//testtest
System.out.println(jsonObject.getJSONObject("citys").getJSONObject("A").toString());//{'AAAA':'BBBB'}

jgszhuzhu 2012-08-27
  • 打赏
  • 举报
回复
哪个具体写出来啊
fire_fire_fire 2012-08-27
  • 打赏
  • 举报
回复
jgszhuzhu 2012-08-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
JSONObject
JSONStringer
JSONArray
JSONTokener
JSONException
[/Quote]
能不能具体写下啊
franzhong 2012-08-27
  • 打赏
  • 举报
回复
JSONObject
JSONStringer
JSONArray
JSONTokener
JSONException

80,337

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧