Fork me on GitHub

I'm trying to use specter to help me generate a map structure that can be converted to an XML string using With a map function, I can do this:

(mapv (fn [[k v]] {:tag k :content [v]})
      {:A 1
       :B 2
       :C 3})
;; => [{:tag :A, :content [1]} {:tag :B, :content [2]} {:tag :C, :content [3]}]
I tried to do something similar with transform:
  (fn [[k v]] {:tag k :content [v]})
  {:A 1
   :B 2
   :C 3})
;; Execution error (UnsupportedOperationException) at com.rpl.specter.navs/eval18222$fn (navs.cljc:124).
nth not supported on this type: PersistentArrayMap
I don't understand the error that specter is giving me. Is it possible to do what I want to do with specter?


@jvtrigueros transform replaces navigated vals and otherwise leaves the structure the same


since you are navigating to key/value pairs, it's expecting you to replace the key/value pairs with key/value pairs


for this particular use case specter isn't really relevant


I understand, I'm using specter to select values in a deeply nested XML tree which worked great. I was trying to use it to generate the XML map datastructure as well. I can simply do the mapv operation as the input map is fairly flat.