specter

Latest version: 1.1.3
2019-08-29T18:35:40.004200Z

I'm trying to use specter to help me generate a map structure that can be converted to an XML string using clojure.data.xml. 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:
(r/transform
  r/ALL
  (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?

nathanmarz 2019-08-29T19:39:13.004600Z

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

nathanmarz 2019-08-29T19:39:35.005100Z

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

2019-08-29T19:39:43.005300Z

I see

nathanmarz 2019-08-29T19:39:59.005600Z

for this particular use case specter isn't really relevant

2019-08-29T19:42:55.007300Z

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.