convertFromJson static method
converts json ThreatListString to List
Implementation
static List<ThreatWeight> convertFromJson(String threatWeightJson) {
try {
List<dynamic> jsonData = jsonDecode(threatWeightJson);
return jsonData
.map((threatWeight) => ThreatWeight.fromJson(threatWeight))
.toList();
} on FormatException {
throw CustomFormatException(
message:
'\n that is the wrong format for ThreatWeight: \n $threatWeightJson \n right String format: [{"threat":{"threatId":"value","name":"value"},"weight":"value"}] \n Note: threatId is optional');
}
}