The article Parsing Complex JSON in Flutter is very good, but I was looking for something shorter, a quick reference with examples.
If I have a simple JSON string like this:
{
"name" : "Mary",
"age" : 30
}
How do I convert it to a Dart object? Or a Dart object to JSON?
Setup
Import the builtin convert
library, which includes the jsonDecode()
and jsonEncode()
methods:
import 'dart:convert';