I have a Spray.io directive that handles a POST and I want to use Jerkson (scala interface for Jackson) to parse the incoming JSON into the appropriate class.
post {
path("") {
entity(as[String]) { stuff =>
complete {
parse[User](stuff)
}
}
}
}
The issue is that when I go to compile, Spray goes looking for a Marshaller:
[error] C:\project\src\main\scala\com\project\AccountService\controllers\Users.scala:53:
could not find implicit value for evidence parameter of type
spray.httpx.marshalling.Marshaller[com.project.AccountService.models.User]
[error] parse[User](stuff)
[error] ^
[error] one error found
Do I need to write a custom Marhsaller for this? Or is my directive not written properly? And if I do need one, any good examples out there?
Thanks!
This managed to get the job done:
post {
path("") {
entity(as[String]) { body =>
val user = parse[User](body)
complete(generate(user))
}
}
}
Looks like since I wasn't returning a string in the complete
it started looking for a Marshaller to Marshall my User object.