If you want wanted to pickle into bytes, then the code will look like this:
import scala.pickling._
import binary._
val pckl = List(1, 2, 3, 4).pickle
val bytes = pckl.value
If you wanted json, the code would look almost the exact same with a minor change of imports:
import scala.pickling._
import json._
val pckl = List(1, 2, 3, 4).pickle
val json = pckl.value
How the object is pickled depends on the import type that you chose under scala.pickling
(being either binary
or json
). Import binary
and the value
property is an Array[Byte]
. Import json
and it's a json String
.