Without using Apache Commons Beanutils what is the most simple way to create a method to convert a POJO into a Map<String,Object>
Asked
Active
Viewed 947 times
2
quarks
- 31,298
- 67
- 266
- 478
-
You're trying to convert all fields? So if you have a field `foo` containing `1` and a field `bar` containing a String, you want a `Map` containing `"foo"`->`Integer(1)` and `"bar"`->`"whatever baz"`? – nanofarad Jun 27 '13 at 12:25
-
looking into the docs you provided describe(Object bean) method will help you I guess – Bhavik Shah Jun 27 '13 at 12:27
-
http://stackoverflow.com/a/2989585/106261 – NimChimpsky Jun 27 '13 at 12:31
1 Answers
8
Without an external jar, I think the only way is to use the dark side of the force : the reflection api.
NimChimpsky
- 44,999
- 57
- 192
- 304
-
1
-
1Fear leads to anger; anger leads to hate; hate leads to reflection; reflection leads to suffering? – André Stannek Jun 27 '13 at 13:22