Map转成对象
时间:2021-06-28 15:12:53
收藏:0
阅读:18
把Map转成实体对象:
LoginEntity loginEntity = new LoginEntity();//任意实体类
Map map = new HashMap();
Field[] fields = object.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
try {
map.put(field.getName(), field.get(loginEntity));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
原文:https://www.cnblogs.com/osmoba/p/14943309.html
评论(0)