Using JSON
Most mobile and web apps use JSON for tasks such asexchanging data with a web server.This page discusses Dart support for JSON serialization and deserialization:converting Dart objects to and from JSON.
Libraries
The following libraries and packages are useful across Dart platforms:
dart:convertConverters for both JSON and UTF-8(the character encoding that JSON requires).
package:json_serializableAn easy-to-use code generation package.When you add some metadata annotationsand use the builder provided by this package,the Dart build system generates serialization and deserialization code for you.
package:built_valueA powerful, opinionated alternative to json_serializable.
Flutter resources
- JSON and serialization
- Shows how Flutter apps can serialize and deserialize bothwith dart:convert and with json_serializable.
Web app resources
- AngularDart Tutorial, part 6: HTTP
- Illustrates how a Dart web app can interact with aRESTful backend using JSON data.
- Using HTTP resources with HttpRequest
- Demonstrates how to use HttpRequest to exchange data with a web server.Part of the dart:html library tour.
VM resources
- Write HTTP Clients & Servers
- Walks through how to implement command-line clients and serversthat exchange JSON data.