Is it possible to serialize an ActorRef into JSON using Play-JSON?

28 views
Skip to first unread message

Chris Ridmann

unread,
Apr 17, 2015, 8:42:49 AM4/17/15
to play-fr...@googlegroups.com
Hello,

I'm using akka persistence and am serializing all of my events into JSON using the play-json library.  For the most part this has been smooth sailing, however I can't seem to figure how to do this with ActorRef's - it may not be possible with how I'm trying to do it.

Here is what I have thus far:

  implicit val actorRefFormat: Format[ActorRef] = new Format[ActorRef] {
    def reads(json: JsValue): JsResult[ActorRef] = {
      JsSuccess(Actor.noSender) // ???
    }

    def writes(o: ActorRef): JsValue = {
      val identifier = Serialization.serializedActorPath(o)
      Writes.StringWrites.writes(identifier)
    }
  }



 It seems the `Writes` will work because it doesn't depend on having an `ActorSystem` in scope.  How would I do this for the `Read`?

Thanks!
-Chris
Reply all
Reply to author
Forward
0 new messages