/**
* 对象转化为Map
*
* @param obj
* @return
* @throws Exception
*/
public static Map<String, Object> objectToMap01(Object obj) throws Exception {
if (obj == null) {
return null;
}
Map<String, Object> map = new HashMap<String, Object>();
Field[] declaredFields = obj.getClass().getDeclaredFields();
for (Field field : declaredFields) {
field.setAccessible(true);
map.put(field.getName(), field.get(obj));
}
return map;
}
java对象转换为map
最新推荐文章于 2024-05-28 18:07:16 发布