DEV Community

Cover image for Decode Tagged JSON into a Sealed Model
YeLinAung for dust

Posted on Originally published at dust-codegen.pages.dev

Decode Tagged JSON into a Sealed Model

A manual tagged JSON switch beside a Dust Serde sealed model

How do you decode tagged JSON into a sealed model?

Without code generation, you usually read the discriminator and map each value yourself. With Dust, define the tag and variants on the sealed class. Dust generates the JSON helpers, while your app can keep using a normal exhaustive switch.

See the Dust sealed-class guide.

Dust #Serde #Dart #CodeGeneration

Top comments (0)