public static Map<String, Object> getMapFromObject(Object obj) { Map<String, Object> map = new HashMap<String, Object>(); Field[] fields = obj.getClass().getDeclaredFields(); for (Field field : fields) { try { field.setAccessible(true); Object value = field.get(obj); map.put(field.getName(), value); } catch (Exception e) { } } return map; }