You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
}
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).
Activity
travisbrown commentedon 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
Configurationdefinition (if it uses one).orlandojsjr commentedon Oct 5, 2017
This example keeps falling for me.
I'm using Scala Version 2.12.3
froth commentedon Apr 4, 2019
This has been fixed in the meantime by @gvolpe . Current examples work fine.