encode/decode json 的 Scala 3 + http4s 问题
Scala 3 + http4s problem with encode/decode json
我有一个 Scala 3 项目(3.0.0 版),我正在尝试使用 http4s 构建简单的 Rest API。
我对 decoding/encoding JSON 有疑问。
我正在基于 http4s.g8.
构建我的代码
问题发生在 this line:
implicit val jokeDecoder: Decoder[Joke] = deriveDecoder[Joke]
编译错误:
no implicit argument of type deriving.Mirror.Of[com.example.quickstart.Jokes.Joke]
was found for parameter A
of method deriveDecoder
in object semiauto
Scala 3 中是否有一些变化使其与众不同?
我的依赖关系
scalaVersion := "3.0.0"
val Http4sVersion = "0.23.6"
val CirceVersion = "0.14.1"
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-blaze-server" % Http4sVersion,
"org.http4s" %% "http4s-blaze-client" % Http4sVersion,
"org.http4s" %% "http4s-circe" % Http4sVersion,
"org.http4s" %% "http4s-dsl" % Http4sVersion,
"io.circe" %% "circe-core" % CirceVersion,
"io.circe" %% "circe-generic" % CirceVersion
)
final case class Joke(joke: String) extends AnyVal
是cuprit。重写为
final case class Joke(joke: String)
它应该有效
我有一个 Scala 3 项目(3.0.0 版),我正在尝试使用 http4s 构建简单的 Rest API。
我对 decoding/encoding JSON 有疑问。
我正在基于 http4s.g8.
构建我的代码问题发生在 this line:
implicit val jokeDecoder: Decoder[Joke] = deriveDecoder[Joke]
编译错误:
no implicit argument of type
deriving.Mirror.Of[com.example.quickstart.Jokes.Joke]
was found for parameterA
of methodderiveDecoder
in objectsemiauto
Scala 3 中是否有一些变化使其与众不同?
我的依赖关系
scalaVersion := "3.0.0"
val Http4sVersion = "0.23.6"
val CirceVersion = "0.14.1"
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-blaze-server" % Http4sVersion,
"org.http4s" %% "http4s-blaze-client" % Http4sVersion,
"org.http4s" %% "http4s-circe" % Http4sVersion,
"org.http4s" %% "http4s-dsl" % Http4sVersion,
"io.circe" %% "circe-core" % CirceVersion,
"io.circe" %% "circe-generic" % CirceVersion
)
final case class Joke(joke: String) extends AnyVal
是cuprit。重写为
final case class Joke(joke: String)
它应该有效