Decoding into Case Classes
Map JSON onto your types.
Decoders Map JSON to Types
A Decoder[A] knows how to read a Json value into a Scala type A.
Circe provides decoders for primitives and collections out of the box, and can build decoders for your own case classes automatically.
A Target Case Class
Suppose your API returns user records. Model the shape with a case class whose field names match the JSON keys.
Matching names is what lets Circe derive a decoder with no manual wiring.
case class User(name: String, age: Int, admin: Boolean)All lessons in this course
- Parsing JSON
- Decoding into Case Classes
- Encoding to JSON
- Custom Codecs