Closed kul closed 10 years ago
Oh! just saw this https://github.com/ptaoussanis/nippy#custom-types-v21-alpha---subject-to-change
Can working with records be made more seamless?
Hi Kul, your example should work:
(defrecord MyRec [a b]) => taoensso.nippy.MyRec
(thaw (freeze (MyRec. 1 2))) => #taoensso.nippy.MyRec{:a 1, :b 2}
What version of Nippy+Clojure are you using?
nippy "2.5.2" and clojure "1.4.0" , Can this still be done in 1.4.0?
Yes, should work. Just tried 2.5.2 against Clojure 1.4.0 and it works as expected:
(defrecord MyRec [a b]) => user.MyRec
(n/thaw (n/freeze (MyRec. 1 2))) => #user.MyRec{:a 1, :b 2}
This is also covered by the unit tests. I'd check that your environment is configured correctly. Try lein clean
, restart your REPL, make sure your type is actually defined in the appropriate namespace. Let me know if that helps :-)
This is weird freeze
works correctly but thaw
has problem. But this only happens in my project and works fine with lein try com.taoensso/nippy "2.5.2"
outside project. This may be a jar conflict! I will close this in sometime.
Thanks
Sure, no problem. Things I would focus on checking:
:import
ed the required Record/Type into the namespace that's doing the thawing?lein clean
.Hope that helps, cheers :-)
Closing this, please feel free to reopen if you're still experiencing any problems :-)
How should records be de/serialized ?
Regards