大佬教程收集整理的这篇文章主要介绍了使用FastJson解析Json数据,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
零依赖(没有依赖其它任何类库除了JDK)
List<String> listString = JSON.parseArray(jsonString,String.class);(4)List< @H_94_93@map<String,Object> >
List<Map<String,Object>> listMap = JSON.parSEObject(jsonString,new TypeReference<List<Map<String,Object>>>(){});
{"@R_296_10586@lRecords":2615,
"result":{"code":"200","status":"success"},"list":[{"unuAbnId":"0bcd930f-014c-1000-e003-5f160a0d0114","entNo":"1c2e4ca8-00fa-1000-e000-74590a76bf0f","regNO":"442000600169663","entName":"x","entType":"9910 ","speCause":"3","abnTime":"Mar 13,2015 12:00:00 AM","decOrg":"442020","entNameUrl":"<a href=\".. ","audiTingFileNo":"15000684990326","abnormalID":"fd74013d-014b-1000-e00a-72970a0d0114"},{...},...],"pageNo":1,"pageSize":8,"url":"main/abnInfoPage","selList":[{"unuAbnId":"0bcd930f-014c-1000-e003-5f0f0a0d0114","entNo":"16da9629-0131-1000-e005-3effc0a803a8","regNO":"442000602187424","entNameUrl":"<a href=\"..\">","audiTingFileNo":"15000684990319","topPageNo":1,"@R_296_10586@lPages":327,"prevIoUsPageNo":0,"nextPageNo":2,"bottomPageNo":327 }其中list含有2615条数据,selList含有8条数据,目标是提取selList中entNameUrl的链接(不含a href=)
JSONObject jsonObj = JSON.parSEObject(rawText); JSONArray result = jsonObj.getJSONArray("selList"); List<Link> links= JSON.parseArray(result.toJSONString(),Link.class);其中Link类中要有entNameUrl这个属性,并且setter和getter方法。
public void setEntNameUrl(String entNameUrl) { this.entNameUrl =Html.create(entNameUrl).links().get(); }这里使用了自定方法,其@L_674_22@就是取出字符串中的链接。
JSONObject jsonObj = new JSONObject(rawText); JSONArray jsonArray = result .getJSONArray("selList"); for (int i = 0; i < jsonArray.length; i++) { }
以上是大佬教程为你收集整理的使用FastJson解析Json数据全部内容,希望文章能够帮你解决使用FastJson解析Json数据所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。