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
object KebsProtocol extends KebsCirce import KebsProtocol._ @noflat case class F(i: Int) test("No-flat format - annotation") { val decoder = implicitly[Decoder[F]] val encoder = implicitly[Encoder[F]] decoder.apply(Json.fromFields(Seq("i" -> Json.fromInt(10))).hcursor) shouldBe Right(F(10)) encoder.apply(F(10)) shouldBe Json.fromFields(Seq("i" -> Json.fromInt(10))) }
Test above results in failure. Currently the support for noflat works only when NoFlat trait is mixed in.
noflat
In order to fix this, the following code should be changed so @noflat is taken into account when only KebsCirce trait is extended:
KebsCirce
trait KebsCirce extends AutoDerivation { implicit def flatDecoder[T, A](implicit rep: CaseClass1Rep[T, A], decoder: Decoder[A]): Decoder[T] = decoder.emap(obj => Try(rep.apply(obj)).toEither.left.map(_.getMessage)) implicit def flatEncoder[T, A](implicit rep: CaseClass1Rep[T, A], encoder: Encoder[A]): Encoder[T] = encoder.contramap(rep.unapply) }
KebsSpray is already handling this - it's worth taking a look: https://github.com/theiterators/kebs/blob/bb83e41ec2e3a217719c2da083e99e8ca4eee0ba/spray-json/src/main/scala/pl/iterators/kebs/json/KebsSpray.scala
The text was updated successfully, but these errors were encountered:
NoFlat will be no longer present in kebs 2.0.
Sorry, something went wrong.
No branches or pull requests
Test above results in failure. Currently the support for
noflat
works only when NoFlat trait is mixed in.In order to fix this, the following code should be changed so @noflat is taken into account when only
KebsCirce
trait is extended:KebsSpray is already handling this - it's worth taking a look: https://github.com/theiterators/kebs/blob/bb83e41ec2e3a217719c2da083e99e8ca4eee0ba/spray-json/src/main/scala/pl/iterators/kebs/json/KebsSpray.scala
The text was updated successfully, but these errors were encountered: