Playframework 使用喷射json播放框架
我可以在play框架中使用spray json进行json序列化吗? 我试过了,但似乎不起作用 我尝试了一个简单的动作Playframework 使用喷射json播放框架,playframework,spray-json,Playframework,Spray Json,我可以在play框架中使用spray json进行json序列化吗? 我试过了,但似乎不起作用 我尝试了一个简单的动作 def getColor(sn: Int ) = Action { import MyJsonProtocol._ val c = Color("color",33,23,99) Ok(c.toJson) } 我得到以下错误 play.sbt.PlayExceptions$Compi
def getColor(sn: Int ) = Action {
import MyJsonProtocol._
val c = Color("color",33,23,99)
Ok(c.toJson)
}
我得到以下错误
play.sbt.PlayExceptions$CompilationException: Compilation error[Cannot write an instance of spray.json.JsValue to HTTP response. Try to define a Writeable[spray.json.JsValue]]
有趣;)我自己通过调用toJson上的prettyPrint方法修复了它
Ok(c.toJson.prettyPrint)