如何在scala上的play框架中使用SORM将id字段添加到JsonObject?

时间:2016-04-28 09:07:10

标签: sorm

这是我的案例类:

case class Admin(name: String, surname: String, login: String, password: String

这是我的json格式化程序:

implicit val adminWrite: Writes[Admin] = (
      (JsPath \ "name").write[String] and
      (JsPath \ "surname").write[String] and
      (JsPath \ "login").write[String] and
      (JsPath \ "password").write[String]
    )(unlift(Admin.unapply))

我得到了什么:

{
name: "ddd",
surname: "ddd",
login: "djamik123",
password: "djamik123"
}

我需要什么:

{
id: 1,
name: "ddd",
surname: "ddd",
login: "djamik123",
password: "djamik123"
}

有没有办法解决这个问题?

0 个答案:

没有答案