JSON deserialization

JSON deserialization turns the text received from an API into typed Dart objects. You decode with jsonDecode, which produces Maps and lists, then build a model, often via a fromJson constructor. This avoids handling untyped map keys throughout the app.

Example

factory Item.fromJson(Map<String, dynamic> j) =>
  Item(nom: j['nom'] as String);

Related concepts

The whole glossary