PolicyRulesWithSubjects.fromJson constructor

PolicyRulesWithSubjects.fromJson(
  1. Map<String, dynamic> json
)

Creates a PolicyRulesWithSubjects from JSON data.

Implementation

factory PolicyRulesWithSubjects.fromJson(Map<String, dynamic> json) {
  final tempNonResourceRulesJson = json['nonResourceRules'];
  final tempResourceRulesJson = json['resourceRules'];
  final tempSubjectsJson = json['subjects'];

  final List<NonResourcePolicyRule>? tempNonResourceRules =
      tempNonResourceRulesJson != null
          ? List<dynamic>.from(tempNonResourceRulesJson)
              .map(
                (e) => NonResourcePolicyRule.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final List<ResourcePolicyRule>? tempResourceRules =
      tempResourceRulesJson != null
          ? List<dynamic>.from(tempResourceRulesJson)
              .map(
                (e) => ResourcePolicyRule.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final List<Subject> tempSubjects = List<dynamic>.from(tempSubjectsJson)
      .map(
        (e) => Subject.fromJson(
          Map<String, dynamic>.from(e),
        ),
      )
      .toList();

  return PolicyRulesWithSubjects(
    nonResourceRules: tempNonResourceRules,
    resourceRules: tempResourceRules,
    subjects: tempSubjects,
  );
}