Posted By

narkisr on 03/29/09


Tagged

serialization clojure


Versions (?)

Serializing Clojure data structures


 / Published in: Lisp
 

print-dup is a multimethod which provides with readable serialization format for Clojure data structures (http://groups.google.com/group/clojure/browse_thread/thread/e704414cf36ef2aa).

  1. ; high-fidelity printing. You can get print-dup behaviour by binding *print-dup*:
  2. (def my-string (binding [*print-dup* true] (pr-str [1 2 3])))
  3. ; or using
  4. (def my-string (with-out-str (print-dup [1 2 3] *out*)))
  5.  
  6. ; de-serialization
  7. (def my-data (with-in-str my-string (read)))

Report this snippet  

You need to login to post a comment.