JSONObject转Bean

我是研究僧i 提交于 2019-12-28 05:44:55
Map<String,Object > dataMap = new HashMap<>() 
Object dormFloor =dataMap.get("dormData");
    //        List<DormInfo> collection =(List<DormInfo>)dataMap.get("dormData");
            List<DormInfo> collection = JSON.parseArray(dataMap.get("dormData").toString() , DormInfo.class);
  //          String js=JSONObject.toJSONString(dormFloor, SerializerFeature.WriteClassName);//将array数组转换成字符串
//            List<DormInfo>  collection = JSONObject.parseArray(js, DormInfo.class);//把字符串转换成集合
for ( DormInfo dorm : collection
                 ) {
             String floorName = dorm.getFloor() ;
             dorm.setLeaveTodayNum("0") ;
             dorm.setNotInNum("0") ;
             for ( Map<String,Object > map : dormLeInfo ) {
                 if(floorName.equals( map.get("name"))){
                     dorm.setLeaveTodayNum(  map.get("leaveTodayNum") == null ? "0" : map.get("leaveTodayNum").toString()  );
                     break ;
                 }
               }
            }

http://www.voidcn.com/article/p-aafzgvtr-brz.html 调试报类型不匹配

https://blog.csdn.net/jeffleo/article/details/73612224 该连接信息调试显示正常

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!