I would like to decompose a nested map in Clojure into a sequence of key-value pairs. For example, let's have this map:
{:a :b
:c {:d {:e :f
:g :h}
:i :j}}
This map decomposed should look like this:
[[:a :b]
[:c {:d {:e :f
:g :h}
:i :j}]
[:d {:e :f
:g :h}]
[:e :f]
[:g :h]
[:i :j]]
Order of the output does not matter.
I'm thinking about solving this with a recursive function, tree-seq
, or clojure.walk
. I suspect I might be missing something from the Clojure standard library. What would be the best solution to approach this?