Json marshaller is in SprayJsonSupport trait, so just import it into the scope:
import spray.httpx.SprayJsonSupport._
And with this marshaller you can remove respondWithMediaType(application/json)
directive, cause it Json is marshaled only to application/json
media type:
implicit def sprayJsonMarshaller[T](implicit writer: RootJsonWriter[T], printer: JsonPrinter = PrettyPrinter) =
Marshaller.delegate[T, String](ContentTypes.`application/json`) { value ⇒
val json = writer.write(value)
printer(json)
}