i'm trying to marshall a string into a custom case class that I have. Here is the code I am trying to use
import spray.httpx.SprayJsonSupport._
import NflWeekJsonProtocol._
path("playerScore") {
get {
parameters('gsisId.as[String] ?, 'week.as[NflWeek] ?, 'playerId.as[String]).as(PlayerScoreRequest) {
playerScoreRequest : PlayerScoreRequest =>
}
}
}
and here is the error that I am getting:
[error] /home/chris/dev/suredbits-dfs/src/main/scala/com/suredbits/dfs/nfl/scoring/NflPlayerScoringService.scala:40: too many arguments for method parameters: (pdm: spray.routing.directives.ParamDefMagnet)pdm.Out
[error] parameters('gsisId.as[String] ?, 'week.as[NflWeek] ?, 'playerId.as[String]).as(PlayerScoreRequest) {
[error] ^
[error] one error found
NflWeekJsonProtocol
represents a way to serializes the case class NflWeek
. I thought this was all I would be required to do to get this working, what am I missing?
EDIT:
object NflWeekJsonProtocol extends DefaultJsonProtocol {
implicit object NflWeekFormat extends RootJsonFormat[NflWeek] {
override def read(jsValue: JsValue) = {
jsValue match {
case JsString(string) => NflWeekFactory.factory(string)
case _ => throw new RuntimeException("NFLWeek should always be reprsented by a JsString")
}
}
override def write(week: NflWeek) = {
JsString(week.toString)
}
}
}