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?