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
I am using io.circe.generic.extras.deriveEnumerationDecoder for my adt (sample code)
sealed trait Org
object Org {
case object Github extends Org {
implicit val decoder: Decoder[Github] = <decode it into a JString of "github">
}
case object GItlab extends Org {
implicit val decoder: Decoder[Gitlab] = <decode it into a JString of "gitlab">
}
implicit val decoder: Decoder[Org] = deriveEnumerationDecoder[Org]
I found out that deriveEnumerationDecoder ignored my custom decoders, but rather creating new ones for my adts.
I noticed this because it actually docode my case object Github into a JString of "Github" instead of "github".
Do you have any suggestions to let generic-extras to take my custom codecs in scope?
Thanks in advance!
The text was updated successfully, but these errors were encountered:
My current workaround is to stick my logic into io.circe.generic.extras.deriveEnumerationDecoder's prepare method making sure I got a all lower case JString.
Could you correct me if I did wrong, or point me a better way please?
@ChengGitderiveEnumerationDecoder is really only intended for the simple case where you have a bunch of case objects and want to decode them by name—unlike deriveDecoder, it doesn't respect custom decoders. You might be able to do something like this by having your custom decoders be EnumerationDecoder instances, but I'm not sure whether even that would work, and if it did it still wouldn't really be a supported use case.
Hi,
I am using
io.circe.generic.extras.deriveEnumerationDecoder
for my adt (sample code)I found out that
deriveEnumerationDecoder
ignored my custom decoders, but rather creating new ones for my adts.I noticed this because it actually docode my
case object Github
into a JString of "Github" instead of "github".Do you have any suggestions to let
generic-extras
to take my custom codecs in scope?Thanks in advance!
The text was updated successfully, but these errors were encountered: