case class CustomerInfo (
customerId: Long,
customerName: String,
cameAt: String,
staffId:String,
staffName:String
)
case class CustomerResult (
customers:Option[Seq[CustomerInfo]] = None
){
def toJson = Json.toJson(this)
}
implicit val customerInfoWrites: Writes[CustomerInfo] = (
(JsPath \ "customer_id").write[Long] and
(JsPath \ "customer_name").write[String] and
(JsPath \ "came_at").write[String] and
(JsPath \ "staff_id").write[String] and
(JsPath \ "staff_name").write[String]
)(unlift(CustomerInfo.unapply))
implicit val custmerResultWrites: Writes[CustomerResult] = (
(JsPath \ "customers").writeNullable[Seq[CustomerInfo]]
)(unlift(CustomerResult.unapply))
the second method is error custmerResultWrites, beacuse It have only one JsPath write.If i add one more part to CustomerResult ,error is ok. error:
found : CustomersSearchResult.this.CustomerResult => Option[Seq[CustomersSearchResult.this.CustomerInfo]]
required: play.api.libs.json.Writes[Seq[CustomersSearchResult.this.CustomerInfo]]