Skip to main content
Version: 2.x

Integrations

An interop module connects ZIO JSON to another library. It provides JsonEncoder, JsonDecoder and related instances for that library's types, or adapts ZIO JSON codecs to that library's own abstractions. Each module is a separate artifact, so you only add the ones you use.

Modulesโ€‹

Each interop module has a short page with installation steps and examples:

ModuleWhat it gives you
http4sEntityEncoder and EntityDecoder instances for http4s 0.23 built from ZIO JSON codecs, so routes can read and write JSON bodies.
refinedEncoders, decoders and map-key codecs for refined types (A Refined P); decoding checks the predicate.
Scalaz 7.xAn encoder and a decoder for Scalaz's IList.
enumeratumTraits and builders that give enumeratum enums (string enums and value enums) their codecs and map-key codecs.

Platforms and Scala Versionsโ€‹

The modules are not all published for the same platforms. The table below follows the project build (build.sbt and project/BuildHelper.scala):

ArtifactJVMScala.jsScala NativeScala 2.12Scala 2.13Scala 3
zio-json-interop-http4sYesNoNoYesYesYes
zio-json-interop-refinedYesYesYesYesYesYes
zio-json-interop-scalaz7xYesYesYesYesYesNo
zio-json-interop-enumeratumYesYesYesYesYesYes

The http4s module is a JVM-only project. The other three are cross-built, so in a Scala.js or Scala Native project you add them with %%% instead of %%:

libraryDependencies += "dev.zio" %%% "zio-json-interop-refined" % "1.1.3"

The Scalaz module has no Scala 3 artifact. The enumeratum module works on Scala 3, but enumeratum's own findValues macro needs the -Yretain-trees compiler option there for value enums, see enumeratum on Scala 3.

The other add-on modules (YAML, golden testing and @jsonDerive macros) are listed with their platforms in the Modules section of the Introduction page.

ZIO Chat

๐Ÿ”ฅ Ignite your ZIO journey with ZIO Chat! ๐Ÿ”ฅ Ready to unravel the intricacies of ZIO? As your trusty sidekick, I'm here to light the way. No matter if you're wandering through functional forests or traversing effectful landscapes, I've got answers to keep you on track. Your ZIO adventure starts here โ€“ ask me anything and let's explore together!