LocationPolicy.fromJson constructor

LocationPolicy.fromJson(
  1. Object? j
)

Implementation

factory LocationPolicy.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return LocationPolicy(
    locations: switch (json['locations']) {
      null => {},
      Map<String, Object?> $1 => {
        for (final e in $1.entries)
          decodeString(e.key): LocationPolicyLocation.fromJson(e.value),
      },
      _ => throw const FormatException('"locations" is not an object'),
    },
    targetShape: switch (json['targetShape']) {
      null => null,
      Object $1 => decodeString($1),
    },
    zones: switch (json['zones']) {
      null => [],
      List<Object?> $1 => [
        for (final i in $1) LocationPolicyZoneConfiguration.fromJson(i),
      ],
      _ => throw const FormatException('"zones" is not a list'),
    },
  );
}