ResourceRequirements.fromJson constructor

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

Creates a ResourceRequirements from JSON data.

Implementation

factory ResourceRequirements.fromJson(Map<String, dynamic> json) {
  final tempClaimsJson = json['claims'];
  final tempLimitsJson = json['limits'];
  final tempRequestsJson = json['requests'];

  final List<ResourceClaim>? tempClaims = tempClaimsJson != null
      ? List<dynamic>.from(tempClaimsJson)
          .map(
            (e) => ResourceClaim.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final Map<String, String>? tempLimits = tempLimitsJson != null
      ? Map<String, String>.from(tempLimitsJson)
      : null;

  final Map<String, String>? tempRequests = tempRequestsJson != null
      ? Map<String, String>.from(tempRequestsJson)
      : null;

  return ResourceRequirements(
    claims: tempClaims,
    limits: tempLimits,
    requests: tempRequests,
  );
}