convertFromJson static method

List<ThreatScore> convertFromJson(
  1. String threatScoreJson
)

converts json ThreatList to List

Implementation

static List<ThreatScore> convertFromJson(String threatScoreJson) {
  try {
    List<dynamic> jsonData = jsonDecode(threatScoreJson);
    return jsonData
        .map((threatMap) => ThreatScore.fromJson(threatMap))
        .toList();
  } on FormatException {
    throw CustomFormatException(
        message:
            '\n that is the wrong format for ThreatScore:\n $threatScoreJson \n right String format:\n [{"threat":{"threatId":"value","name":"value"}, "score":"value"}] \n Note: threatId is optional');
  }
}