json - Play Framework, JSON 重载方法值 [申请]

标签 json scala playframework-2.0

我已经多次使用 Json Write 和 Read,但是这次出现了一个愚蠢的错误,我在那里找不到任何拼写错误..请在这里帮助我.. ^^

Overloaded method value [apply] cannot be applied to (models.Expense_PIheader => (String, java.util.Date, String, String, Integer))

这是我的案例类:

case class Expense_PIheader(pi_id: String, pi_due_date: Date, supplier_id: String, staff_id: String, status: Integer)

这是我的 JSON:

object Expense_PIheader {
    implicit val ExpensePIheaderWrites: Writes[Expense_PIheader] = (
        (JsPath \ "pi_id").write[String] and
        (JsPath \ "pi_due_date").write[Date] and
        (JsPath \ "supplier_id").write[String] and
        (JsPath \ "staff_id").write[String] and
        (JsPath \ "status").write[Int] 
    )(unlift(Expense_PIheader.unapply))

    implicit val ExpensePIheaderReads: Reads[Expense_PIheader] = (
        (JsPath \ "pi_id").read[String] and
        (JsPath \ "pi_due_date").read[Date] and
        (JsPath \ "supplier_id").read[String] and
        (JsPath \ "staff_id").read[String] and
        (JsPath \ "status").read[Int] 
    )(Expense_PIheader.apply _)
}

最佳答案

您的案例类有一个类型为Integerstatus 字段。

写入和读取需要一个Int 类型的status 字段。

更改一个或另一个以使类型匹配并且它将起作用。

关于json - Play Framework, JSON 重载方法值 [申请],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23358963/

相关文章:

php - 将带有非数字键的 PHP 数组编码为 JSON 数组

java - 将数据从 url 保存到 JSON 对象

scala - 如何依赖其他任务并在 SBT 0.10 中执行您的代码?

scala - 使用 DataFrame 解析混合内容 XML

scala - 如何从其他包中引用 scala 枚举

scala - List[String] 的 QueryStringBinder

java - 如何将JSON对象解析为 `Map<String, HashSet<String>>`

java - 如何验证 Jackson 中的特定 json 结构?

scala - SBT 中使用的 `addCommandAlias` 方法中的第一个分号是什么?

java - 如何在 Controller 外注入(inject) MessagesApi?