JSONObject转Bean
程序员文章站
2022-06-09 12:05:51
...
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 该连接信息调试显示正常