Do you know a function that takes a Clojure string and converts it to a map. For example, if the function gets the string
:first "John" :last "Lukas" :city "London"
it returns a map with the previous key-value relations.
You can use the clojure.end/read-string function for this. It makes sure that nobody injects code to your system, but otherwise will parse clojure data structures. Prepend "{" and append "}" to make it a map, that can be parsed that way:
(def stringtoparse ":first \"John\" :last \"Lukas\" :city \"London\"")
(clojure.edn/read-string (str "{" stringtoparse "}"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With