Skip to content

Instantly share code, notes, and snippets.

@martinklepsch
Created August 25, 2014 21:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinklepsch/2dcf28d2eaef25a4034c to your computer and use it in GitHub Desktop.
Save martinklepsch/2dcf28d2eaef25a4034c to your computer and use it in GitHub Desktop.
(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