How can I pretty print a PersistentHashMap in Clojure to a string?

后端 未结 4 1588
情歌与酒
情歌与酒 2021-02-03 20:43

How can I pretty print a PersistentHashMap in Clojure to a string? I am looking for something like:

(str (pprint {... hash map here...})

which

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-03 21:26

    This should help:

    (clojure.pprint/write {:a 1 :b 2} :stream nil)
    

    according to clojure.pprint/write documentation

    Returns the string result if :stream is nil or nil otherwise.

提交回复
热议问题