我正在使用spray-json将自定义对象列表转换为JSON。以下是我的案例类及其JsonProtocol。
case class ElementResponse(name: String, symbol: String, code: String, pkwiu: String, remarks: String, priceNetto: BigDecimal, priceBrutto: BigDecimal, vat: Int, minInStock:Int, maxInStock: Int)
object JollyJsonProtocol extends DefaultJsonProtocol with SprayJsonSupport {
implicit val elementFormat = jsonFormat10(ElementResponse)
}
当我尝试将其放入这样一个路由中:
get {
complete {
List(new ElementResponse(...), new ElementResponse(...))
}
}
我收到一个错误信息,内容为:
could not find implicit value for evidence parameter of type spray.httpx.marshalling.Marshaller[List[pl.ftang.scala.polka.rest.ElementResponse]]
也许你知道问题所在?
我正在使用Scala 2.10.1版本,搭配spray 1.1-M7和spray-json 1.2.5。
List
。示例链接在此:https://github.com/spray/spray/blob/master/examples/spray-client/simple-spray-client/src/main/scala/spray/examples/Main.scala - opyate