Skip to content

Instantly share code, notes, and snippets.

@alexhall
Created June 17, 2013 19:38
Show Gist options
  • Save alexhall/5799651 to your computer and use it in GitHub Desktop.
Save alexhall/5799651 to your computer and use it in GitHub Desktop.
Flattens a nested map structure.
(defn unnest-keys [x]
(into {} (mapcat (fn [[k v]]
(if (map? v)
(map (fn [[k' v']]
[(str (name k) "." k') v'])
(unnest-keys v))
[[(name k) v]]))
x)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment