I have a Java object obj that has attributes obj.attr1, obj.attr2 etc. The attributes are possibly accessed through an extra level of
Here's a rough approximation, hopefully enough to get you pointed in the right direction:
public Map getMap(Object o) {
Map result = new HashMap();
Field[] declaredFields = o.getClass().getDeclaredFields();
for (Field field : declaredFields) {
result.put(field.getName(), field.get(o));
}
return result;
}