is there a better way to take a map with string keys and convert to keyword keys?
5 │ (defn props []
6 │ (let [file (io/file "field-map.properties")
7 │ data (p/load-from file)]
8 │ (zipmap (map keyword (keys data)) (vals data)) ))
{"two" "dos", "one" "uno", "three" "a long thing"}
is what would be in data
There’s fmap
in contrib… let me see
actually - no fmap is for map keys
(into {} (for [[k v] data] [(keyword k)] v)
That’s an option, but zipmap reads pretty well
oh
(clojure.walk/keywordize-keys data)
duh
ahh ok
hmm so its not actually a map but a java.util.Properties object ...
playing in repl
ah
a is my object
(clojure.walk/keywordize-keys (into {} a))
that works
cool
ok thanks 🙂
ok i have another question
i am making a war file and handing it to a guy
that reads a properties file ... using clojurewerkz/propertied library ...
if I read the file and store into a variable
and compile to jar ....
will the var work ?
or will it contain the values it had when i first compiled ?
i guess i can try it
hmm i used clojure.walk by calling it fully qualified.. and when i make uberjar it complains
Did you require it?
no
ok it works now 😉
and i answered my own questions 🙂
clojure is the most awesome language
open for any suggestions… a brief tour of clojure.. https://github.com/AustinClojure/workshop-docs/blob/add-basics/Pages/2-basics.md
mainly for a reference during the workshop