convertToJson static method

String convertToJson(
  1. List<ThreatWeight> threatWeights
)

convert from ThreatWeight List to threatWeight json

Implementation

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