I'm trying to map JSON i/p to my case class CacheRequest.
request is POST.
I'm new to Scala and Akka.
import org.json4s.{DefaultFormats, Formats}
implicit val formats: Formats = DefaultFormats
val route: Route = traceContextAwareRoute {
pathPrefix(system.name) {
post {
path("sample") {
entity(as[CacheRequest]) { x => {
val cacheRequest: CacheRequest = CacheRequest(x.a, x.b, x.c, x.d, x.e, x.f)
onComplete(getSystemStock(cacheRequest)) {
(response: Try[Option[CacheResponse]]) => complete(processResponse(response))
}
}
}
}
}
}
My case class is like this.
case class CacheRequest(a: String,
b: String,
c: Int,
d: Int,
e: Int,
f: Int)
Getting an Error Like
could not find implicit value for parameter um: akka.http.scaladsl.unmarshalling.FromRequestUnmarshaller[mcc.movie.common.model.CacheRequest]
not enough arguments for method as: (implicit um: akka.http.scaladsl.unmarshalling.FromRequestUnmarshaller[mcc.movie.common.model.CacheRequest])akka.http.scaladsl.unmarshalling.FromRequestUnmarshaller[mcc.movie.common.model.CacheRequest]
I'supposed to do this using json4s.
Any help regarding this is fine for me.