![](/img/trans.png)
[英]Scala, Circe, Http4s - is it any way to encode Throwable in Circe?
[英]Scala 3 + http4s problem with encode/decode json
它应该很简单,但是我已经为此苦苦挣扎了一段时间。 我有一个 Scala 3 项目(3.0.0 版本),我正在尝试使用 http4s 构建简单的 Rest API。 问题在于解码/编码 json。 我正在基于https://github.com/http4s/http4s.g8构建我的代码。 该问题发生在https://github.com/http4s/http4s.g8/blob/0.23/src/main/g8/src/main/scala/%24package__packaged%24/Jokes.scala 中。
编译错误:
no implicit argument of type deriving.Mirror.Of[com.example.quickstart.Jokes.Joke] was found for parameter A of method deriveDecoder in object semiauto
implicit val jokeDecoder: Decoder[Joke] = deriveDecoder[Joke]
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
)
最后一个案例类 Joke(joke: String) extends AnyVal 是cuprit
将其改写为
最后一个案例类笑话(笑话:字符串)
它应该工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.