readJsonList static method

List<Map<String, dynamic>> readJsonList(
  1. String json
)

Parses a JSON string into a list of Map objects.

May throw a FormatException if the input string is not valid JSON.

Implementation

static List<Map<String, dynamic>> readJsonList(String json) {
  dynamic jsonObj = jsonDecode(json);

  if (jsonObj is List<dynamic>) {
    return List<Map<String, dynamic>>.from(
      jsonObj.map(
        (result) => Map<String, dynamic>.from(result),
      ),
    );
  }

  return [];
}