taoensso/nippy

Serialise deserialise with nippy to a string

piotr-yuxuan opened this issue · 2 comments

Thank you for this library. Indeed it's quite fast! I believe it might be worth add in the readme an example of how to serialise and then deserialise to a string. The naive approach is to use slurp on the byte[] array returned by nippy. This doesn't work.

(defn nippy-serialise-to-string
  ^String [o]
  (.encodeToString (java.util.Base64/getEncoder) (nippy/freeze o {})))

(defn nippy-deserialise-from-string
  ^Object [^String s]
  (nippy/thaw (.decode (java.util.Base64/getDecoder) s)))

Will push a PR when I have some time.

Just added manually.