fromJson static method

Organization? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static Organization? 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(() {
      assert(json.containsKey(r'id'), 'Required key "Organization[id]" is missing from JSON.');
      assert(json[r'id'] != null, 'Required key "Organization[id]" has a null value in JSON.');
      assert(json.containsKey(r'name'), 'Required key "Organization[name]" is missing from JSON.');
      assert(json[r'name'] != null, 'Required key "Organization[name]" has a null value in JSON.');
      assert(json.containsKey(r'slug'), 'Required key "Organization[slug]" is missing from JSON.');
      assert(json[r'slug'] != null, 'Required key "Organization[slug]" has a null value in JSON.');
      assert(json.containsKey(r'role'), 'Required key "Organization[role]" is missing from JSON.');
      assert(json[r'role'] != null, 'Required key "Organization[role]" has a null value in JSON.');
      assert(json.containsKey(r'createdAt'), 'Required key "Organization[createdAt]" is missing from JSON.');
      assert(json[r'createdAt'] != null, 'Required key "Organization[createdAt]" has a null value in JSON.');
      assert(json.containsKey(r'updatedAt'), 'Required key "Organization[updatedAt]" is missing from JSON.');
      assert(json[r'updatedAt'] != null, 'Required key "Organization[updatedAt]" has a null value in JSON.');
      return true;
    }());

    return Organization(
      id: mapValueOfType<String>(json, r'id')!,
      name: mapValueOfType<String>(json, r'name')!,
      slug: mapValueOfType<String>(json, r'slug')!,
      description: mapValueOfType<String>(json, r'description'),
      logoUrl: mapValueOfType<String>(json, r'logoUrl'),
      role: mapValueOfType<String>(json, r'role')!,
      memberCount: mapValueOfType<int>(json, r'memberCount'),
      workspaceCount: mapValueOfType<int>(json, r'workspaceCount'),
      workspaces: OrganizationWorkspacesInner.listFromJson(json[r'workspaces']),
      createdAt: mapDateTime(json, r'createdAt', r'')!,
      updatedAt: mapDateTime(json, r'updatedAt', r'')!,
    );
  }
  return null;
}