From a0f5cbf086ec576fcc2595fb86186fb4b80c8d53 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Sun, 8 May 2011 14:37:57 +0200 Subject: [PATCH] Docs: Fix of sample in 'Serializer API using reflection' (cherry picked from commit dfc2ba15efe49ee81aecf3b64e5291aa1ec487c0) --- akka-docs/scala/serialization.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/akka-docs/scala/serialization.rst b/akka-docs/scala/serialization.rst index 8ac5e1c8e1..2005ec99a4 100644 --- a/akka-docs/scala/serialization.rst +++ b/akka-docs/scala/serialization.rst @@ -468,21 +468,22 @@ You can also use the Serializer abstraction to serialize using the reflection ba .. code-block:: scala - import akka.serialization.Serializer import scala.reflect.BeanInfo + import akka.serialization.Serializer @BeanInfo case class Foo(name: String) { def this() = this(null) // default constructor is necessary for deserialization } - val foo = new Foo("bar") - val json = Serializer.ScalaJSON.out(foo) + val foo = Foo("bar") - val fooCopy = Serializer.ScalaJSON.in(json) // returns a JsObject as an AnyRef + val json = Serializer.ScalaJSON.toBinary(foo) - val fooCopy2 = Serializer.ScalaJSON.in(new String(json)) // can also take a string as input + val fooCopy = Serializer.ScalaJSON.fromBinary(json) // returns a JsObject as an AnyRef - val fooCopy3 = Serializer.ScalaJSON.in[Foo](json).asInstanceOf[Foo] + val fooCopy2 = Serializer.ScalaJSON.fromJSON(new String(json)) // can also take a string as input + + val fooCopy3 = Serializer.ScalaJSON.fromBinary[Foo](json).asInstanceOf[Foo] Classes without a @BeanInfo annotation cannot be serialized as JSON. So if you see something like that: