fromJson static method
Returns a new DecryptedContentDto instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static DecryptedContentDto? fromJson(dynamic value) {
if (value is DecryptedContentDto) {
return value;
}
if (value is Map) {
final json = {"compoundValue": [], "ratio": [], "range": [], ...value.cast<String, dynamic>()};
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "DecryptedContentDto[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "DecryptedContentDto[$key]" has a null value in JSON.');
});
return true;
}());
return DecryptedContentDto(
stringValue: mapValueOfType<String>(json, r'stringValue'),
numberValue: mapValueOfType<double>(json, r'numberValue'),
booleanValue: mapValueOfType<bool>(json, r'booleanValue'),
instantValue: mapDateTime(json, r'instantValue', ''),
fuzzyDateValue: mapValueOfType<int>(json, r'fuzzyDateValue'),
binaryValue: mapValueOfType<String>(json, r'binaryValue'),
documentId: mapValueOfType<String>(json, r'documentId'),
measureValue: MeasureDto.fromJson(json[r'measureValue']),
medicationValue: MedicationDto.fromJson(json[r'medicationValue']),
timeSeries: TimeSeriesDto.fromJson(json[r'timeSeries']),
compoundValue: DecryptedServiceDto.listFromJson(json[r'compoundValue']) ?? const [],
ratio: MeasureDto.listFromJson(json[r'ratio']) ?? const [],
range: MeasureDto.listFromJson(json[r'range']) ?? const [],
);
}
return null;
}