Parse url query string into clojure map

Possible duplicate:
What is the easiest way to parse URL parameters in Clojure?

I would like to take a line like:

"Q = foo + bar & x = 14 & y = hello"

and turn it into a map like:

{: q "foo + bar" ,: x 14 ,: y "hello"}

I am sure that for such a problem there is an elegant idiomatic solution.

+4
source share
1 answer
(->> (split "q=foo+bar&x=14&y=hello" #"&") (map #(split % #"=")) (map (fn [[kv]] [(keyword k) v])) (into {})) 
+4
source

All Articles