ClusterRoleBinding.fromJson constructor

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

Creates a ClusterRoleBinding from JSON data.

Implementation

factory ClusterRoleBinding.fromJson(Map<String, dynamic> json) {
  final tempApiVersionJson = json['apiVersion'];
  final tempKindJson = json['kind'];
  final tempMetadataJson = json['metadata'];
  final tempRoleRefJson = json['roleRef'];
  final tempSubjectsJson = json['subjects'];

  final String? tempApiVersion = tempApiVersionJson;
  final String? tempKind = tempKindJson;
  final ObjectMeta? tempMetadata =
      tempMetadataJson != null ? ObjectMeta.fromJson(tempMetadataJson) : null;
  final RoleRef tempRoleRef = RoleRef.fromJson(tempRoleRefJson);

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

  return ClusterRoleBinding(
    apiVersion: tempApiVersion,
    kind: tempKind,
    metadata: tempMetadata,
    roleRef: tempRoleRef,
    subjects: tempSubjects,
  );
}