Fork me on GitHub
#specter
<
2018-05-24
>
huthayfa21:05:48

is there a function to collect the path to a given key

huthayfa21:05:08

if i have map like this {"properties": { "assets": {"target-key"}}}, I want to collect the path to target-key which is [properties assets target-key]

huthayfa21:05:24

is there a function in specter that does this

nathanmarz21:05:42

@huthayfa.ainqawi use the collect navigators

nathanmarz21:05:15

someone just asked this recently

nathanmarz21:05:24

here's a code example:

(def MAP-VALS+ (path ALL (collect-one FIRST) LAST))
(transform [MAP-VALS+ MAP-VALS+ MAP-VALS]
  (fn [k1 k2 v]
    [k1 k2 v]
    )
  {"2018-05-22" {:A {123 "foo"}}})

huthayfa22:05:34

@nathanmarz how do I select the target key