BooPickle is the fastest and most size efficient serialization (aka pickling) library that works on both Scala and Scala.js. It encodes into a binary format instead of the more customary JSON. A binary format brings efficiency gains in both size and speed, at the cost of legibility of the encoded data. BooPickle borrows heavily from both uPickle and Prickle so special thanks to Li Haoyi and Ben Hutchison for those two great libraries!
Add following dependency declaration to your Scala project
"io.suzaku" %% "boopickle" % "1.5.0"
On a Scala.js / Scala Native project the dependency looks like this
"io.suzaku" %%% "boopickle" % "1.5.0"
To use it in your code, simply import the Default object contents. All examples in this document assume this import is present.
import boopickle.Default._
To serialize (pickle) something, just call Pickle.intoBytes
with your data. This will produce a binary ByteBuffer
containing an encoded version
of your data.
val data = Seq("Hello", "World!")
val buf = Pickle.intoBytes(data)
And to deserialize (unpickle) the buffer, call Unpickle.fromBytes
, specifying the type of your data. BooPickle doesn't encode any type information,
so you must use the same types when pickling and unpickling.
val helloWorld = Unpickle[Seq[String]].fromBytes(buf)
Read the full documentation
See a separate changes document
BooPickle was created and is maintained by Otto Chrons - otto@chrons.me - Twitter: @ochrons.
Special thanks to Li Haoyi and Ben Hutchison for their pickling libraries, which provided more than inspiration to BooPickle.
Contributors: @japgolly, @FlorianKirmaier, @guersam, @akshaal, @cquiroz, @cornerman, @notxcain, @lolgab, @Philippus