How can I pretty print a PersistentHashMap in Clojure to a string? I am looking for something like:
(str (pprint {... hash map here...})
which
user=> (import java.io.StringWriter) java.io.StringWriter user=> (use '[clojure.pprint :only (pprint)]) nil user=> (defn hashmap-to-string [m] (let [w (StringWriter.)] (pprint m w)(.toString w))) #'user/hashmap-to-string user=> (hashmap-to-string {:a 1 :b 2}) "{:a 1, :b 2}\n"