Integrated sjson type class based serialization into Akka - some backward incompatible changes there
This commit is contained in:
parent
48250c2730
commit
59a2881f36
7 changed files with 221 additions and 58 deletions
|
|
@ -128,11 +128,25 @@ object Serializer {
|
|||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
object ScalaJSON extends ScalaJSON
|
||||
trait ScalaJSON extends Serializer {
|
||||
trait ScalaJSON {
|
||||
import dispatch.json._
|
||||
import sjson.json._
|
||||
import sjson.json.JsonSerialization
|
||||
|
||||
var classLoader: Option[ClassLoader] = None
|
||||
|
||||
def tojson[T](o: T)(implicit tjs: Writes[T]): JsValue = JsonSerialization.tojson(o)(tjs)
|
||||
|
||||
def fromjson[T](json: JsValue)(implicit fjs: Reads[T]): T = JsonSerialization.fromjson(json)(fjs)
|
||||
|
||||
def tobinary[T](o: T)(implicit tjs: Writes[T]): Array[Byte] = JsonSerialization.tobinary(o)(tjs)
|
||||
|
||||
def frombinary[T](bytes: Array[Byte])(implicit fjs: Reads[T]): T = JsonSerialization.frombinary(bytes)(fjs)
|
||||
|
||||
// backward compatibility
|
||||
// implemented using refelction based json serialization
|
||||
def toBinary(obj: AnyRef): Array[Byte] = SJSONSerializer.SJSON.out(obj)
|
||||
|
||||
// FIXME set ClassLoader on SJSONSerializer.SJSON
|
||||
def fromBinary(bytes: Array[Byte], clazz: Option[Class[_]]): AnyRef = SJSONSerializer.SJSON.in(bytes)
|
||||
|
||||
import scala.reflect.Manifest
|
||||
|
|
@ -144,6 +158,7 @@ object Serializer {
|
|||
SJSONSerializer.SJSON.in(bytes)(m)
|
||||
}
|
||||
}
|
||||
object ScalaJSON extends ScalaJSON
|
||||
|
||||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue