Add following dependency declaration to your Scala project
"io.suzaku" %% "boopickle" % "1.3.0"
On a Scala.js project the dependency looks like this
"io.suzaku" %%% "boopickle" % "1.3.0"
To use it in your code, simply import the Default object contents. All examples in this document assume this import is present.
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)
BooPickle has built-in support for most of the regular Scala types, including
- common types:
- collections, both mutable and immutable, including:
Maps and any
case classes and
case objects (via a macro)
traits as a base for a class hierarchy