我有一个用户模型
case class User(name: String, email: String, password: Option[String] = None, key: Option[UUID] = None)
使用spray-json编组器
object UserJsonSupport extends DefaultJsonProtocol with SprayJsonSupport {
implicit val userFormat = jsonFormat4(User)
}
在我将关键字段从Option[String]
转换为Option[UUID]
之前,它是工作正常的,现在我遇到了两个编译错误:
Error:(8, 40) could not find implicit value for evidence parameter of type in.putfood.http.UserJsonSupport.JF[Option[java.util.UUID]]
implicit val userFormat = jsonFormat4(User)
^
Error:(8, 40) not enough arguments for method jsonFormat4: (implicit evidence$16: in.putfood.http.UserJsonSupport.JF[String], implicit evidence$17: in.putfood.http.UserJsonSupport.JF[String], implicit evidence$18: in.putfood.http.UserJsonSupport.JF[Option[String]], implicit evidence$19: in.putfood.http.UserJsonSupport.JF[Option[java.util.UUID]], implicit evidence$20: ClassManifest[in.putfood.model.User])spray.json.RootJsonFormat[in.putfood.model.User].
Unspecified value parameters evidence$19, evidence$20.
implicit val userFormat = jsonFormat4(User)
^
我的理解是,自从这个问题得到解决以来,它应该能够在不需要提供自己的UUID反序列化程序的情况下正常工作。我错了还是还有其他原因?
它可能不喜欢被放在
Option
内部吗?