Reference
The reference describes everything ZIO JSON provides: every type, method, annotation and option, with its signature, its default and what it does. Use it when you know what you want to call and need the exact details.
The other sections answer other questions. Getting Started and the tutorials teach the library step by step. The How-to Guides solve one task each. The Concepts pages explain why ZIO JSON works the way it does.
Type Classesโ
The core of the library. An encoder turns a value into JSON, a decoder reads it back, and a codec is both.
- Type Classes: how the type classes relate, and where instances come from.
- JsonEncoder: turns a Scala value into JSON. Covers
toJson,contramap, the combinators and writing an encoder by hand. - JsonDecoder: reads JSON into a Scala value. Covers
fromJson,map,mapOrFail, the combinators, missing fields and writing a decoder by hand. - JsonCodec: an encoder and a decoder packed together, and how to transform and combine codecs.
- JsonFieldEncoder and JsonFieldDecoder: the type classes for
Mapkeys and the key types supported out of the box. - Built-in Instances: every type ZIO JSON encodes and decodes out of the box, with its JSON shape and how lenient its decoder is.
- Errors: what a failed decode returns, the common messages, and how error paths are written.
Derivationโ
How ZIO JSON writes codecs for your own case classes and sealed traits, and the tools that change what it writes.
- Derivation: how derivation starts on Scala 2 and Scala 3, and which tool to use for which change.
- JsonCodecConfiguration: the options that apply to every type derived where the configuration is in scope.
- Annotations: the annotations that change one type or one field.
- @jsonDerive Macro Annotation: the Scala 2 annotation that writes the derived codec into the companion object.
Data and Modulesโ
The JSON tree, and the APIs of the optional modules. The Installation and Modules sections of the Introduction page show how to add each module.
- JSON AST: the
Jsontype, cursors, and reading, transforming, combining and folding JSON trees. - YAML: reading and writing YAML with your JSON codecs, the options, and the decoding limits.
- Streaming API: the JVM-only ZIO Streams encoders, decoders, pipelines and file helpers, and how they report errors.
- Golden Testing API:
goldenTest,GoldenConfiguration, the golden file lifecycle and format, and how the module root is found.