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!
Written by Jens Haase
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Clojure
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#