Dart apps read and write JSON all the time.
One small problem appears in many projects.
The API uses snake_case. The Dart model uses camelCase.
You can map every key by hand. That works, but the same casing rule is repeated in every model.
Dust Serde lets the model declare the rule once.
Use @SerDe(renameAll: SerDeRename.snakeCase). Dust applies that rule when decoding and encoding the model.
The field stays displayName in Dart. The JSON key stays display_name on the wire.
That keeps the model easy to read and keeps API naming rules out of handwritten mapping code.
Read the Dust rename strategies guide.

Top comments (0)