I have the following structure
(def aaa '({:a "read" :b "one"} {:a "open" :b "two"}) )
I need to rename all :a keys for example to :c and I want to get
({:c "read" :b "one"} {:c "open" :b "two"})
You are looking for clojure.set
's rename-keys function.
Used with map
, you'll get the result you want:
(map #(clojure.set/rename-keys % {:a :c}) [{:a "read" :b "one"} {:a "open" :b "two"}])
=> ({:b "one", :c "read"} {:b "two", :c "open"})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With