Skip to content

Instantly share code, notes, and snippets.

@drewr
Created November 19, 2008 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewr/26536 to your computer and use it in GitHub Desktop.
Save drewr/26536 to your computer and use it in GitHub Desktop.
(use '[clojure.contrib.str-utils])
(defn map->querystring [m]
(let [join-pair (fn [[k v]]
(str-join "=" [(.toUpperCase (name k)) v]))]
(str-join "&"
(reduce (fn [acc pair]
(conj acc (join-pair pair))) [] m))))
(map->querystring {:class "RES" :mlsnum "23823" :format "COMPACT"})
; => "CLASS=RES&MLSNUM=23823&FORMAT=COMPACT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment