Scala Pickling usage MyObject -> Array[Byte] -> MyObject -
i trying new scala pickling library presented @ scaladays 2013: scala pickling
what missing simple examples how library used.
i understood can pickle object unpickle again that:
import scala.pickling._ val pckl = list(1, 2, 3, 4).pickle val lst = pckl.unpickle[list[int]] in example, pckl of type pickle. use of type , how can example array[byte] of it?
if want wanted pickle bytes, code this:
import scala.pickling._ import binary._ val pckl = list(1, 2, 3, 4).pickle val bytes = pckl.value if wanted json, code exact same minor change of imports:
import scala.pickling._ import json._ val pckl = list(1, 2, 3, 4).pickle val json = pckl.value how object pickled depends on import type chose under scala.pickling (being either binary or json). import binary , value property array[byte]. import json , it's json string.
Comments
Post a Comment