У меня есть класс, который выглядит примерно так:
import java.time.OffsetDateTime
import spray.json._
import DefaultJsonProtocol._
sealed trait Person {
def firstName: String
def country: String
def lastName: String
def salary: Option[BigDecimal]
}
case class InternalPerson(
firstName: String,
country: String,
lastName: Option[BigDecimal],
salary: Option[BigDecimal]
) extends Person
object Person {
def fromName(name: Name, country: String, salary: Option[BigDecimal]): Person = {
InternalPerson(
firstName = name.firstName,
lastName = name.lastName,
country = country,
salary = salary
)
}
}
object PersonJsonProtocol extends DefaultJsonProtocol {
implicit val personFormat = jsonFormat4(Person.apply)
}
Я просто пытаюсь добавить поддержку json в мой класс.всякий раз, когда я импортирую протокол и spray.json._
из других классов, я получаю:
Note: implicit value personFormat is not applicable here because it comes after the application point and it lacks an explicit result type
и
value apply is not a member of object of Person
любую идею о том, какиметь поддержку Json для сопутствующих объектов, которая расширяет черту в scala?