我正在尝试使用 play-json 读取将以下 Json 转换为结果案例类。但是,我坚持将经度和纬度 json 值转换为 Point 对象的语法,同时将其余 json 值转换为相同的结果 BusinessInput 对象。这在语法上可能吗?
case class BusinessInput(userId: String, name: String, location: Point, address: Option[String], phonenumber: Option[String], email: Option[String])
object BusinessInput {
implicit val BusinessInputReads: Reads[BusinessInput] = (
(__ \ "userId").read[String] and
(__ \ "location" \ "latitude").read[Double] and
(__ \ "location" \ "longitude").read[Double]
)(latitude: Double, longitude: Double) => new GeometryFactory().createPoint(new Coordinate(latitude, longitude))