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

Open
eliaslevy opened this Issue Aug 3, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@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
}
@travisbrown

This comment has been minimized.

Show comment
Hide comment
@travisbrown

travisbrown Aug 4, 2017

Member

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).

Member

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).

@orlandojsjr

This comment has been minimized.

Show comment
Hide comment
@orlandojsjr

orlandojsjr Oct 5, 2017

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

orlandojsjr commented Oct 5, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment