convertToJson static method

String convertToJson(
  1. List<ThreatScore> threatScores
)

convert from ThreatScore List to threatScore json

Implementation

static String convertToJson(List<ThreatScore> threatScores) {
  try {
    List<Map<String, dynamic>> jsonData =
        threatScores.map((threatScore) => threatScore.toJson()).toList();
    return jsonEncode(jsonData);
  } on FormatException {
    throw CustomFormatException(
        message: "Fails to Convert List<ThreatScore> $threatScores to json");
  }
}