其他分享
首页 > 其他分享> > Object 转对象 的问题

Object 转对象 的问题

作者:互联网

在度娘上搜了好久大多数是用 :
方法1:  ObjectMapper mapper = new ObjectMapper();
PageBean<MessageListVO> strPageBean = mapper.readValue(jsonString, PageBean.class);
方法2:(时间格式有问题)
ObjectMapper objectMapper = new ObjectMapper();
Object businsInfo = plaProcessDTO.getBusinessInfo();
EquipmentRepairDto appPlanEquipmepairDto = objectMapper.convertValue(busissInfo, EquipmentRepairDto.class);
这两个都有缺陷










正确的转换方式为:
JSONObject jsonObject = (JSONObject) planFloessDTO.getBusssInfo();
EquipmentRepairDto appPlanEqentRepairDto = jsonObject.toJavaObject(EquRepairDto.class);

标签:EquipmentRepairDto,对象,JSONObject,Object,问题,PageBean,class,ObjectMapper
来源: https://www.cnblogs.com/zxy-come-on/p/16379687.html