Is there any way to preserve JS objects through transit serialization/deserialization? E.g. if I have {:a 12 :thing #js {:one "two"}} it comes out the other side as a cljs datastructure like {:a 12 :thing {"one" "two"}}.
at reader side, will be something like:
(t/read (t/reader rdr :json
{:handlers {"js" (t/read-handler clj->js)}}))I wonder how terrible it would be to do:
(t/read (t/reader rdr :json
{:handlers {"js" (t/read-handler cljs.reader/read-string)}}))
And have the writer do pr-str to get EDN.probably yes, via read/write handlers
may be tricky to implement the implement the writer Handler protocol to "generic J object", but seems to be doable
Ok i will research this, thank you.
You can use clojure.edn/read-string in cljs Don't forget to require this ns before use EDN performance in cljs really bad. I don't have numbers but once I moved one endpoint from EDN to transit and went from "takes a few seconds" to "instant"
Thanks for the heads up!
(the other side of a round trip I mean)