Question

I have used Json Write and Read several times, but this time there is a silly error, I can't find any typo there.. Please help me here.. ^^

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

This is my case class:

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

And this is my 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 _)
}
Was it helpful?

Solution

Your case class has a status field of type Integer.

Writes and Reads expect a status field of type Int.

Change one or the other so the types match and it will work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top