【发布时间】:2015-04-18 22:48:00
【问题描述】:
我正在尝试从喷雾路由中的完整指令中返回一个列表。
complete {
List("hello")
}
但是,我收到一个错误 -
Expression of type List[String] doesn't conform to expected type ToResponseMarshallable
我在使用 Seq 时遇到了同样的错误。我看到在 spray-httpx documentation 中默认不提供 List 和 Seq 的编组器。但是,spray-json 在其 DefaultJsonProtocol 中提供了编组支持。我已经在我的代码中导入了 spray.httpx.SprayJsonSupport._ 和 spray.json.DefaultJsonProtocol._ ,但这也没有帮助。
知道如何使用 spray-json 编组 List/Seq 吗?还是我必须编写自己的 Marshaller?
(我的scala版本是2.11.4)
【问题讨论】:
标签: scala scala-collections spray spray-json