23

How does one use cljs.pprint to return a string?

(cljs.pprint/pprint '(foo bar))

Would like this to return a string, rather than have a side effect of printing it.

Similar to this question, but for CLJS, not CLJ.

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

Community
  • 1
  • 1
elliot42
  • 3,694
  • 3
  • 26
  • 27

1 Answers1

30

This should work:

(with-out-str (cljs.pprint/pprint '(foo bar)))
ClojureMostly
  • 4,652
  • 2
  • 22
  • 24