title: How to serialize objects from/to json in spray with defaultFormats?
body: <p>I've got a code that looks like that.</p>
  
  <pre><code>import akka.actor.{Props, ActorRef, Actor}
  import akka.util.Timeout
  import org.json4s.DefaultFormats
  import spray.routing.HttpService
  import spray.httpx.Json4sSupport
  import scala.concurrent.Await
  import scala.concurrent.duration._
  import akka.pattern.ask
  
  /**
   * Created by mihaildoronin on 06.10.15.
   */
  class ProcessesService() extends Actor with HttpService {
  
  
    def actorRefFactory = context
    def receive = runRoute(route)
  
    val systemActor = context.actorOf(Props[SystemActor])
    implicit val json4sFormats = DefaultFormats
    implicit val timeout = Timeout(5 seconds)
  
    val route = path("processes") {
      get {
        parameters('fromId.as[Int], 'count.as[Int]).as(GetProcessesCommand) { command =&gt;
          complete {
            val response = Await.result(systemActor ? command, timeout.duration).asInstanceOf[CursoredResponse]
            response
          }
        }
  
      } ~
      post {
        entity(as[RegisterProcessCommand]) { command =&gt;
          complete {
            val result = Await.result(systemActor ? command, timeout.duration).asInstanceOf[Long]
          }
        }
      }
    } ~
    pathPrefix("processes" / IntNumber) { id =&gt;
        complete {
        val process = Await.result(systemActor ? GetProcessCommand(id), timeout.duration).asInstanceOf[Process]
        process
      }
    }
  }
  </code></pre>
  
  <p>It gives me errors like that</p>
  
  <pre><code>Error:(28, 11) type mismatch;
   found   : CursoredResponse
   required: spray.httpx.marshalling.ToResponseMarshallable
            response
            ^
  </code></pre>
  
  <p>But in this <a href="http://kufli.blogspot.ru/2013/08/sprayio-rest-service-json-serialization.html" rel="nofollow">tutorial</a> a similar code seems to work. I've overridden json4sFormats and made them implicit, I'm using case classes, what am I missing here?
  I'm new to scala and spray, so It's not clear to me.</p>