Search code examples
javadictionarypojo

Convert a POJO to a <K,V> map


Possible Duplicate:
How to convert a Java object (bean) to key-value pairs (and vice versa)?

What is the best way to convert a List<POJO> to a List<Map<K,V>>. Is there a custom method/ API?

K = field name of the POJO and V is the corresponding value

public class POJO implements Serializable{

String name;
String age;
//getters and setters
}

Solution

  • BeanMap from Apache Commons does the job