您能否演示一下如何在Scala和Play Framework 2.1-RC2中为我的课程定义json writer?
Could you please demostrate how I can define json writer for my class in Scala and Play Framework 2.1-RC2 ?
文档非常混乱(并且将成为Web开发人员社区广泛采用Scala/Play的重大障碍).例如,不仅不清楚确切的以下代码在哪里(摘自 此处 )应该位于
The documentation is quite confusing (and will be significant obstacle for wider adoption of Scala/Play by web-developer community). For example not only it's unclear where exactly following code (taken from here) should be located
implicit val taskWrites = ( (__ \ "id").write[String] ~ (__ \ "label").write[Boolean] ~ )(unlift(Task.unapply)),但是如果我将其放在object定义中,它也是不可编译的.播放给我以下错误
but it's also not compilable if I put it inside object definition. Play gives me following error
not found: value __这是我的Task.scala
Here is my Task.scala
pastebin/hG8F6Gqk
推荐答案嗯,事实证明问题很明显.我忘了导入play.api.libs.functional.syntax._.
Well, turned out the problem was obvious. I forgot to import play.api.libs.functional.syntax._.
更多推荐
如何在Play + Scala中为自定义对象定义json编写器?
发布评论