spray-json kann Map nicht marshallen [String, String]

Ich habe die folgende Routeneinstellung, aber wenn meine Karte im ersten vollständigen Block zurückgegeben wird, erhalte ich eine Fehlermeldung:

could not find implicit value for evidence parameter of type spray.httpx.marshalling.Marshaller[scala.collection.immutable.Map[String,String]]

import spray.routing.HttpService
import akka.actor.Actor
import spray.http.HttpRequest
import spray.routing.RequestContext
import spray.json.DefaultJsonProtocol._


class UserServiceActor extends Actor with RestUserService {
  def actorRefFactory = context
  def receive = runRoute(linkRoute)

}

trait RestUserService extends HttpService {

  val userService = new LinkUserService

  def linkRoute = 
    pathPrefix("user" / Segment) {
      userId =>
        path("link") {
          parameters('service ! "YT") {
            complete {
              Map("status"-> "OK", "auth_url" -> "http://mydomain.com/auth")
            }
          }
        }
    }
}

Gemäßdieser Test Ich sollte in der Lage sein, eine Map nach json zu konvertieren, wenn DefaultJsonProtocol._ importiert wird, aber selbst das schlägt fehl:

val map:Map[String, String] = Map("hi"->"bye")
map.toJson

Cannot find JsonWriter or JsonFormat type class for scala.collection.mutable.Map[String,String]

Nicht sicher, was los ist :(

Antworten auf die Frage(1)

Ihre Antwort auf die Frage