Skip to content
New issue

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

ConfiguredJsonCodec example failing #722

eliaslevy opened this issue Aug 3, 2017 · 3 comments

ConfiguredJsonCodec example failing #722

eliaslevy opened this issue Aug 3, 2017 · 3 comments


Copy link

@eliaslevy eliaslevy commented Aug 3, 2017

This simple example, given on the documentation, fails on Scala 2.11.11:

import io.circe.generic.extras._, io.circe.syntax._

@ConfiguredJsonCodec case class Bar(@JsonKey("my-int") i: Int, s: String)

Bar(13, "Qux").asJson

with the error:

<console>:17: error: could not find Lazy implicit value of type io.circe.generic.extras.decoding.ConfiguredDecoder[Bar]
       @ConfiguredJsonCodec case class Bar(@JsonKey("my-int") i: Int, s: String)

to fix it, one must define the implicit to return the Configuration within the class' object:

object Bar {
  implicit val config: Configuration = Configuration.default
Copy link

@travisbrown travisbrown commented Aug 4, 2017

Good catch. The problem here is that all of the code blocks on the page are compiled with the previous blocks' definitions in context, so this example is picking up the configuration from the previous block.

In this case the configuration could go either in the companion object or in any enclosing scope. I don't have a strong opinion about which we should use in these docs, but definitely think each example should contain its own Configuration definition (if it uses one).

Copy link

@orlandojsjr orlandojsjr commented Oct 5, 2017

This example keeps falling for me.
I'm using Scala Version 2.12.3

Copy link

@froth froth commented Apr 4, 2019

This has been fixed in the meantime by @gvolpe . Current examples work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.