All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.circe.generic.extras.encoding.UnwrappedEncoder.scala Maven / Gradle / Ivy

The newest version!
package io.circe.generic.extras.encoding

import io.circe.{ Encoder, Json }
import shapeless.{ ::, Generic, HNil, Lazy }

abstract class UnwrappedEncoder[A] extends Encoder[A]

final object UnwrappedEncoder {
  implicit def encodeUnwrapped[A, R](
    implicit
    gen: Lazy[Generic.Aux[A, R :: HNil]],
    encode: Encoder[R]
  ): UnwrappedEncoder[A] = new UnwrappedEncoder[A] {
    override def apply(a: A): Json =
      encode(gen.value.to(a).head)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy