Can I use spectre to recursively transform java.util.HashMap of java.util.HashMaps to regular clojure maps?
I'm basically trying to go from the top here, where all the maps are java.util.HashMap, to the bottom, where all maps are IAssociative:
{"name" "foo"
"children" {"bar" {"name" "bar"
"children" {}}
"baz" {"name" "baz"
"children" {"quux" {"name" "quux"
"children" {}}}}}}
;;=> (addition of `ref`, keywordize the keys, make standard IAssociative)
{:name "foo"
:children {:bar {:name "bar"
:children {}
:ref "foo/bar"}
:baz {:name "baz"
:children {:quux {:name "quux"
:children {}
:ref "foo/baz/quux"}}
:ref "foo/baz"}}
:ref "foo"}
Had an implementation using both clojure.walk and spectre, but want to do it in 1 pass, if possible
I can select each with:
(def HASH-MAPS
(sp/recursive-path
[]
p
(sp/stay-then-continue
(sp/must "children")
sp/MAP-VALS
p)))
(clojure.pprint/pprint
(sp/select
[:root HASH-MAPS]
{:root hm}))
It's the transform in one pass that's getting me confused >.<