fromJson static method

MedicalDevice? fromJson(
  1. dynamic value
)

Returns a new MedicalDevice instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static MedicalDevice? 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 "MedicalDevice[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "MedicalDevice[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return MedicalDevice(
      id: mapValueOfType<String>(json, r'id'),
      rev: mapValueOfType<String>(json, r'rev'),
      deletionDate: mapValueOfType<int>(json, r'deletionDate'),
      identifiers: Identifier.listFromJson(json[r'identifiers'])!,
      created: mapValueOfType<int>(json, r'created'),
      modified: mapValueOfType<int>(json, r'modified'),
      author: mapValueOfType<String>(json, r'author'),
      responsible: mapValueOfType<String>(json, r'responsible'),
      labels: CodingReference.listFromJson(json[r'labels'])!.toSet(),
      codes: CodingReference.listFromJson(json[r'codes'])!.toSet(),
      endOfLife: mapValueOfType<int>(json, r'endOfLife'),
      externalId: mapValueOfType<String>(json, r'externalId'),
      name: mapValueOfType<String>(json, r'name'),
      type: mapValueOfType<String>(json, r'type'),
      brand: mapValueOfType<String>(json, r'brand'),
      model: mapValueOfType<String>(json, r'model'),
      serialNumber: mapValueOfType<String>(json, r'serialNumber'),
      parentId: mapValueOfType<String>(json, r'parentId'),
      picture: json[r'picture'] is List ? (json[r'picture'] as List).cast<String>() : const [],
      properties: Property.listFromJson(json[r'properties'])!.toSet(),
      systemMetaData: SystemMetaDataOwner.fromJson(json[r'systemMetaData']),
    );
  }
  return null;
}