为什么Spray error"找不到参数marshaller的隐含值"?

时间:2014-12-28 15:24:45

标签: spray spray-json

我使用spray-json将一些case类转换为json,但是我将转换List转换为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)
  }
}

运行示例后,我收到错误:

  

无法找到参数marshaller的隐含值:spray.httpx.marshalling.ToResponseMarshaller [scala.collection.immutable.List [Post]]

如何解决?

0 个答案:

没有答案