object与map相互转换
public class DomainTransUtils { public static<T> T parseMap2Object(Map<String,Object> paramMap,Class<T> clazz){ return JSONObject.parseObject(JSONObject.toJSONString(paramMap),clazz); } public static Map<String, Object> objectToMap(Object obj) { if (obj == null) { return null; } Map<String, Object> map = new HashMap<String, Object>(); try { Field[] declaredFields = obj.getClass().getDeclaredFields(); for (Field field : declaredFields) { field.setAccessible(true); map.put(field.getName(), field.get(obj)); } } catch (Exception e) { } return map; } }
我不是来改变世界的