json_serializable in Action
Auto-generate model serialization.
The JSON Boilerplate Problem
Writing fromJson and toJson by hand is tedious and error-prone. The json_serializable package generates both for you from a model. 📦
Add the Packages
You need json_annotation as a normal dependency, plus json_serializable and build_runner as dev dependencies for generation.
dependencies:
json_annotation: ^4.9.0All lessons in this course
- Built-in Annotations: override, deprecated
- Writing Custom Annotations
- Code Generation With build_runner
- json_serializable in Action