0Pricing
Dart Academy · Lesson

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.0

All lessons in this course

  1. Built-in Annotations: override, deprecated
  2. Writing Custom Annotations
  3. Code Generation With build_runner
  4. json_serializable in Action
← Back to Dart Academy