asJson method

Map<String, Object?> asJson()

Implementation

Map<String, Object?> asJson() {
  if (body is String) {
    return json.decode(body as String);
  }

  try {
    var temp = body as Map<dynamic, dynamic>;
    return Map<String, Object?>.from(temp);
  } catch (e) {
    throw FormatException('body cannot be casted as Map<String, Object?> (JSON map), type is: ${body.runtimeType}');
  }
}