使用
readNullable
相反例如,如果
act
是
Optional
:
implicit val branchRead : Reads[BranchApplyRequest] = (
(JsPath \ "act").readNullable[String] and
(JsPath \ "st").read[String] and
(JsPath \ "nts").read[String] and
(JsPath \ "bk").read[Int]
)(BranchApplyRequest.apply _)
当然,你的
BranchApplyRequest
将是这样的:
case class BranchApplyRequest(act: Option[String], ...)