We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option
missing required field
(Scala 2)
type WsTag = WsTag.Type object WsTag extends NewtypeWrapped[Option[Long]] with DerivedCirceCodec case class A(wsTag: WsTag, i: Int) implicit val decoder: Decoder[A] = io.circe.generic.semiauto.deriveDecoder println(io.circe.parser.parse("""{"i" : 1}""").value.as[A])
results in
Left(DecodingFailure at .wsTag: Missing required field)
Replacing WsTag with the underlying type Option[Long] in A gets rid of the error:
WsTag
Option[Long]
A
case class A(wsTag: Option[Long], i: Int) println(io.circe.parser.parse("""{"i" : 1}""").value.as[A]) > Right(A(None,1))
The text was updated successfully, but these errors were encountered:
Update: defining Decoder manually as follows:
Decoder
implicit val decoder: Decoder[WsTag] = implicitly[Decoder[Option[Long]]].map(unsafeCoerce)
solves the issue. It looks that the special handling of Option by the decoder may be lost in
trait DerivedCirceDecoder { implicit def jsonDecoder[T, S](implicit builder: HasBuilder.Aux[T, S], dec: Decoder[S], ): Decoder[T] = { jsonDecode(_) } }
Sorry, something went wrong.
No branches or pull requests
(Scala 2)
results in
Replacing
WsTag
with the underlying typeOption[Long]
inA
gets rid of the error:The text was updated successfully, but these errors were encountered: