Provides EntityEncoder and EntityDecoder support using the Fabric JSON library.
Cross-built for Scala 2.13 and 3.
libraryDependencies += "org.http4s" %% "http4s-fabric" % "1.0.0-M48"The milestone number tracks the http4s-core release this version is built against.
A single import supplies an EntityDecoder and EntityEncoder for any type with a Fabric
RW instance — see Convert:
import org.http4s.fabric._
case class Person(name: String, age: Int)
object Person {
implicit val rw: RW[Person] = RW.gen[Person]
}
// Person now encodes to and decodes from application/jsonNote that the derived instances are specialized to cats.effect.IO.
Import the package object for the default behavior, or instantiate FabricEntitySupport
directly with Fabric filters to transform JSON on the
way in and out — for example, to exchange snake_case JSON with camelCase Scala fields:
import fabric.filter._
import org.http4s.fabric.FabricEntitySupport
object SnakeCaseSupport
extends FabricEntitySupport(SnakeToCamelFilter, CamelToSnakeFilter)
import SnakeCaseSupport._