fromJson static method
Returns a new DataSample instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static DataSample? fromJson(dynamic value) {
if (value is Map) {
final json = 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 "DataSample[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "DataSample[$key]" has a null value in JSON.');
});
return true;
}());
return DataSample(
id: mapValueOfType<String>(json, r'id'),
transactionId: mapValueOfType<String>(json, r'transactionId'),
identifiers: Identifier.listFromJson(json[r'identifiers'])!,
batchId: mapValueOfType<String>(json, r'batchId'),
healthcareElementsIds: json[r'healthElementsIds'] is Set
? (json[r'healthElementsIds'] as Set).cast<String>()
: json[r'healthElementsIds'] is List
? ((json[r'healthElementsIds'] as List).toSet()).cast<String>()
: const {},
canvasesIds: json[r'canvasesIds'] is Set
? (json[r'canvasesIds'] as Set).cast<String>()
: json[r'canvasesIds'] is List
? ((json[r'canvasesIds'] as List).toSet()).cast<String>()
: const {},
index: mapValueOfType<int>(json, r'index'),
content: mapValueOfType<Map<String, Content>>(json, r'content')!,
valueDate: mapValueOfType<int>(json, r'valueDate'),
openingDate: mapValueOfType<int>(json, r'openingDate'),
closingDate: mapValueOfType<int>(json, r'closingDate'),
created: mapValueOfType<int>(json, r'created'),
modified: mapValueOfType<int>(json, r'modified'),
endOfLife: mapValueOfType<int>(json, r'endOfLife'),
author: mapValueOfType<String>(json, r'author'),
responsible: mapValueOfType<String>(json, r'responsible'),
comment: mapValueOfType<String>(json, r'comment'),
qualifiedLinks: mapWithMapOfStringsFromJson(json[r'qualifiedLinks']),
codes: CodingReference.listFromJson(json[r'codes'])!.toSet(),
labels: CodingReference.listFromJson(json[r'labels'])!.toSet(),
);
}
return null;
}