Just try json spray, and it looks like I'm having trouble finding my JsonProtocols that I have installed. I have the following dependencies:
"io.spray" % "spray-servlet" % "1.2-M8", "io.spray" % "spray-routing" % "1.2-M8", "io.spray" % "spray-testkit" % "1.2-M8", "io.spray" % "spray-json_2.10" % "1.2.5"
And the following code:
Content.scala
import spray.json.DefaultJsonProtocol case class Content(id:String, name: String, contentType: String, duration: Int) object MyJsonProtocol extends DefaultJsonProtocol { implicit val contentFormat = jsonFormat4(Content) }
I get an error in the line where I return Content in the complete {} block, the error is the following: code below:
Description Resource path location type could not find an implicit value for the proof parameter of type spray.httpx.marshalling.Marshaller [Content] MyService.scala line 32 Scala
import akka.actor.Actor import spray.routing._ import spray.http._ import MediaTypes._ import spray.json.DefaultJsonProtocol import Content import MyJsonProtocol._ class MyServiceActor extends Actor with MyService{ def actorRefFactory = context def receive = runRoute(myRoute) } trait MyService extends HttpService { val myRoute = path("") { get { respondWithMediaType(`application/json`) { // XML is marshalled to `text/xml` by default, so we simply override here complete { new Content("1234", "Some Content", "YT", 60) } } } } }
Can someone see something wrong? This is literally the code of the spray pattern with spray substances sprinkled in
scala
Thadon
source share