playframework scala slick允许多少个属性

Fel*_*lix 2 scala playframework

在我的Playframework scala应用程序中,我具有以下模型:

case class ProcessTemplatesModel(
                                  id: Option[Int] = None,
                                  title: String,
                                  version: String,
                                  createdat: Option[String],
                                  updatedat: Option[String],
                                  deadline: Option[Date],
                                  status: Option[String],
                                  comment: Option[String],
                                  checked: Option[Boolean],
                                  checkedat: Option[Date],
                                  approved: Option[Boolean],
                                  approvedat: Option[Date],
                                  deleted: Boolean,
                                  approveprocess: Int,
                                  trainingsprocess: Option[Int],
                                  previousVersion: Option[Int],
                                  originTemplate: Option[Int],
                                  client: Int,
                                  approveProcessInstance: Option[Int],
                                  responsible: Option[Seq[UserModel]],
                                  accountable: Option[Seq[UserModel]],
                                  consulted: Option[Seq[UserModel]],
                                  informed: Option[Seq[UserModel]])

object ProcessTemplatesModel {
  implicit val processFormat = Json.format[ProcessTemplatesModel]
}
Run Code Online (Sandbox Code Playgroud)

今天我添加了 approveProcessInstance: Option[Int],

现在,我在编译时收到此错误:No unapply or unapplySeq function found...在此行上:implicit val processFormat = Json.format[ProcessTemplatesModel]

为什么在这种情况下失败?

And*_*uba 6

播放JSON中最大22个值,您可以使用3rd party库来增加数量。

这是Play来源中的问题线程:https : //github.com/playframework/playframework/issues/3174

可能的解决方案之一:https : //github.com/xdotai/play-json-extensions

我的例子 build.sbt

libraryDependencies ++= Seq(
  cache,
  filters,
  ws,
  // More than 22 fields in Json
  "ai.x" %% "play-json-extensions" % "0.8.0"
)
Run Code Online (Sandbox Code Playgroud)

对于Play 2.6,您需要使用版本10:

"ai.x" %% "play-json-extensions" % "0.10.0"
Run Code Online (Sandbox Code Playgroud)

然后,在带有JSON的文件中:

import ai.x.play.json.Jsonx

implicit val processFormat = Jsonx.formatCaseClass[ProcessTemplatesModel]
Run Code Online (Sandbox Code Playgroud)

更多详细信息:https : //github.com/xdotai/play-json-extensions#create-explicit-formatter