0

I use a spray-json for convert some case class into json, but i have a troubles with convert List to json:

case class Foo(id: Int)

object FooJsonSupport extends DefaultJsonProtocol with SprayJsonSupport {
  implicit val fooFormats = jsonFormat1(Foo)
}

//and i have a list with Foo:
val list = List(Foo(1), Foo(2), Foo(3))

// and i want to return json response

post {
  respondWithMediaType(`application/json`) {
    complete(list)
  }
}

After I run the sample, I get the error:

could not find implicit value for parameter marshaller: spray.httpx.marshalling.ToResponseMarshaller[scala.collection.immutable.List[Post]]

How to fix it?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
lito
  • 989
  • 8
  • 21
  • have you imported content of FooJsonSupport? Like `import FooJsonSupport._` – Mustafa Simav Dec 29 '14 at 09:08
  • 2
    Can you try the sample with `import akka.http.marshallers.sprayjson._` before `complete(list)`? I also think you should `import FooJsonSupport._` to bring the implicit `fooFormats` into scope. – Jacek Laskowski Dec 29 '14 at 20:06

0 Answers0