3xqr7q
Last Updated: August 10, 2016
·
1.992K
· jenshaase
6a3854ca0601d2d28a2817d8ad904213

Clojurescript, read-string and records

Currently in Clojurescript it is not possible to use cljs.reader/read-string on records. Following script will not work:

(defrecord Test [a b])
(def a (->Test 1 2))
(cljs.reader/read-string (pr-str a)) ; will not work

To fix this you can register a tagged parser to the reader:

(defrecord Test [a b])
(cljs.reader/register-tag-parser! "Test" map->Test)
(def a (->Test 1 2))
(cljs.reader/read-string (pr-str a)) ; works!
Say Thanks
Respond