Fork me on GitHub
#clojure-spec
<
2017-09-06
>
gklijs08:09:30

@arohner I have a private project which I use to serialize specced data, where I also store the used spec in either the bytes or the string. I might make it public. It also makes it possible to set defaults, in order to get correctly specced data back, in case you added required keys.

gklijs08:09:32

It works both with clojure and clojurescript, but it really needs some more work (liks tests for the clojurescript) before I put it public

ikitommi11:09:04

@gklijs can you re-create the spec instances from serialized format in cljs without (form) eval?

gklijs14:09:03

@ikitommi Doent’t know what you mean exactly, i use the form function to re-create the instance, but by assuming the spec is a map with either keys, or merge, and by storing the data in a certain way, I only store the values. If there is an additional required key which wasn’t there when the instance was serialized, either nil is filled in, or the default is it is set.