このタイプのフォーマットを指定できないようです:
sealed trait Baz
object Baz {
case object A extends Baz
implicit val format: OFormat[Baz] = derived.oformat[Baz]()
}
final case class Foo(s: Map[Baz, String])
object Foo {
implicit val format: OFormat[Foo] = Json.format[Foo]
}
I use
```scala
"org.julienrf" %% "play-json-derived-codecs" % "7.0.0"
封印されたトレイトとサブタイプのシリアル化、および Foo 型の通常の Play JSON フォーマット用。
しかし、私はこの問題を抱えています:
No instance of play.api.libs.json.Format is available for scala.collection.immutable.Map[Baz, java.lang.String] in the implicit scope (Hint: if declared in the same file, make sure it's declared before)
play-json-derived-codecs lib が Baz タイプのフォーマットを提供し、それで十分だと思いました。Foo が次のように変更された場合
final case class Foo(s : Map[String,String])
すべてが良いです。