I use camel-snake-kebab quite extensively in one of my applications. Some recent profiling found it to be a bit of a slow point. I'd like to rewrite it in Specter, but I'm struggling a bit.
(cske/transform-keys csk/->snake_case data)
What's the equivalent in Specter to walk the data structure and convert the keys to snake case? This is close to what I want, but doesn't walk the data structure:
(specter/transform
[specter/MAP-KEYS]
csk/->snake_case
{:AThing {:AAThing 12
:A2Thing {:AAAThing "x"}}})
Am I supposed to use specter/walker or specter/ALL somehow?the problem with walker is it's a blind walk that will traverse into all data structures, including records
I find it's usually much better to have a path that's tailored to your representation
so if the structure is always either values or maps in the value position, then you can do something like this:
(def data
{:AThing {:AAThing 12
:A2Thing {:AAAThing "x"}}})
(def ALL-MAPS
(recursive-path [] p
(continue-then-stay
MAP-VALS map? p)))
(transform [ALL-MAPS MAP-KEYS] str data)
;; => {":AThing" {":AAThing" 12, ":A2Thing" {":AAAThing" "x"}}}