Parsing JSON

In this lesson, we discuss converting and parsing a network response into JSON in detail.

Introduction

In the last lesson, you learned how to receive the HttpResponse response from API. In this lesson, you’ll learn to convert responses into JSON, and parse them to render in Flutter ListView.

Parsing JSON

Dart provides the dart:convert library to parse JSON data. The apiResponse is the response returned from http.get(apiEndPoint). The json.decode() method takes the response’s body to parse it into Dart data structures.

//importing the Dart package 
import 'dart:convert';

//Parsing API's HttpResponse to JSON format
json.decode(apiResponse.body)

The dart:convert library

The dart:convert library parses the JSON response into the Dart collection ...