Created
August 25, 2014 21:27
-
-
Save martinklepsch/2dcf28d2eaef25a4034c to your computer and use it in GitHub Desktop.
This file contains 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
(def foo {:bar 1 :moo {:event {:_value 2} :ter {:_value 1} :ber {}} | |
:floors [{:area {:_value 10} :height {}} {:area {} :height {:_value 5}}] | |
:roofs [{:area {}}]}) | |
(defn parse [cursor] | |
(clojure.walk/postwalk (fn [m] | |
(if-let [v (:_value m)] | |
v | |
(cond | |
(and (map? m) (empty? m)) nil | |
(map? m) (into {} (remove (comp nil? second) m)) | |
:else m))) | |
cursor)) | |
;; (parse foo) returns: | |
;; | |
;; {:bar 1, :moo {:event 2, :ter 1}, :floors [{:area 10} {:height 5}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment