Skip to content
Justice Tech School

JSON with dart:convert

jsonEncode and jsonDecode convert between objects and text.

Example
import "dart:convert";
void main() {
  var s = jsonEncode({"name": "Ada", "tags": ["a", "b"]});
  print(s);
  var m = jsonDecode(s) as Map<String, dynamic>;
  print(m["tags"][1]);
}

Exercise

To JSON.

(obj)

Quiz Test

What does jsonDecode return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.