我使用spray-json將自定義對象列表編組爲JSON。我有以下案例類和它的JsonProtocol。spray-json和list marshalling
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噴霧1.1-M7和噴霧JSON 1.2.5
請參閱[本示例](https://github.com/spray/spray/blob/master/examples/spray-client/simple-spray-client/src/main/scala/spray/examples/Main.scala ),它使用'''List'''。 – opyate