Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created January 22, 2010 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jcromartie/283890 to your computer and use it in GitHub Desktop.
Save jcromartie/283890 to your computer and use it in GitHub Desktop.
(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