Clojure kebab case on selected keywords -
i want change key's in large map in clojure. these key's can present @ level in map within required-key
i looking @ using camel-snake-kebab library need change given set of keys in required-key map. doesn't matter if change made in json or map
(def my-map {:allow_kebab_or-snake {:required-key {:must_be_kebab ""}} :allow_kebab_or-snake2 {:optional-key {:required-key {:must_be_kebab ""}}}})
currently using /walk/postwalk-replace fear may change keys not nested within :required-key map
(walk/postwalk-replace {:must_be_kebab :must-be-kebab} my-map))
ummmm.. clarify: want change keys of map?! or associated values?
off-topic: map above not correct (having 2 identical keys :allow_kebab_or_snake - i-m assuming you're underlining point , not showing actual example :))
postwalk-replace replace occurrence of key value.
so if know exact map struct first select sub-struct get-in , use postwalk-replace :
(walk/postwalk-replace {:must_be_kebab :mus-be-kebab} (get-in my-map [:allow_kebab_or_snake :required-key]))
but you'll have assoc
initial map.
you should consider walk function , construct own particular algorithm if interleaved ds complex.
Comments
Post a Comment