Home > Blockchain >  Scala 3 http4s problem with encode/decode json
Scala 3 http4s problem with encode/decode json

Time:11-15

I have a Scala 3 project (3.0.0 version) and I'm trying to build simple Rest API with http4s.

I have a problem with decoding/encoding JSON.

I'm building my code based on http4s.g8.

The issue occurs on this line:

implicit val jokeDecoder: Decoder[Joke] = deriveDecoder[Joke]

Compile error:

no implicit argument of type deriving.Mirror.Of[com.example.quickstart.Jokes.Joke] was found for parameter A of method deriveDecoder in object semiauto

Is there some change in Scala 3 which makes it different?

My dependencies

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
)

CodePudding user response:

final case class Joke(joke: String) extends AnyVal is the cuprit

rewrite it as

final case class Joke(joke: String)

it should work

  • Related