aco*_*ter 1 dictionary clojure
I have a map like {:a "A" :b "B"} and want to convert its keys to strings, e.g. {"a" "A" "b" "B"}.
I have this function, which works:
(defn keyword-keys->strs [m]
(zipmap
(map name (keys m))
(map second (vec m))))
Run Code Online (Sandbox Code Playgroud)
But is there a more idiomatic or purpose-built way to do it?
Thanks!
有一个内置函数可以将映射键递归转换为字符串:
(clojure.walk/stringify-keys {:a "A" :b "B"})
=> {"a" "A", "b" "B"}
(clojure.walk/stringify-keys {:a "A" :b {:c "C"}})
=> {"a" "A", "b" {"c" "C"}}
Run Code Online (Sandbox Code Playgroud)