Clojure's tagged literals and `clojure.edn` namespace functions allow
hyper-local (per call) specification of tagged-literal data readers during
deserialization. The letterpress library provides a similar capability for
printing, allowing per-call specification of print methods and general
recursive printing middleware.
Code and documentation on github:
https://github.com/llasram/letterpress
Example, round-tripping a JVM Class object through EDN:
(require '[letterpress.core :as lp])
(defn class-print [^Class x ^Writer w]
(doto w (.write "#java.lang/class ") (.write (.getName x))))
(defn class-read [x] (Class/forName (name x)))
(->> String
(lp/pr-str {:printers {Class class-print}})
(edn/read-string {:readers {'java.lang/class class-read}}))
;;=> java.lang.String
(class *1)
;;=> java.lang.Class
Comments and pull requests gladly accepted.
-Marshall
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.