java将Object对象转换成实体类对象

java将Object对象转换成实体类对象

大家好,我是架构君,一个会写代码吟诗的架构师。今天说一说java将Object对象转换成实体类对象,希望能够帮助大家进步!!!

ObjectMapper objectMapper=new ObjectMapper();
CirclePropertiesVo circlePropertiesVo=objectMapper.convertValue(polygonGeometricDataDto.getProperties(), CirclePropertiesVo.class);

如果直接转会报错:

CirclePropertiesVo circlePropertiesVo = (CirclePropertiesVo) polygonGeometricDataDto.getProperties();

错误信息:

java.util.LinkedHashMap cannot be cast to com.hzcloud.hz.admin.api.vo.resource.supermap.polygon.child.PolygonPropertiesVo

 

本文来源huayang183,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/18246

发表评论