Created
January 22, 2010 16:33
-
-
Save jcromartie/283890 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn unbean [m] | |
"Tries to recreate a simple JavaBean object from map m" | |
(let [obj (.newInstance (:class m))] | |
(doseq [[k v] (dissoc m :class)] | |
(try | |
(clojure.lang.Reflector/setInstanceField obj (name k) v) | |
(catch Exception _ nil))) | |
obj)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment