BackendRule.fromJson constructor

BackendRule.fromJson(
  1. Object? j
)

Implementation

factory BackendRule.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return BackendRule(
    selector: switch (json['selector']) {
      null => '',
      Object $1 => decodeString($1),
    },
    address: switch (json['address']) {
      null => '',
      Object $1 => decodeString($1),
    },
    deadline: switch (json['deadline']) {
      null => 0,
      Object $1 => decodeDouble($1),
    },
    minDeadline: switch (json['minDeadline']) {
      null => 0,
      Object $1 => decodeDouble($1),
    },
    operationDeadline: switch (json['operationDeadline']) {
      null => 0,
      Object $1 => decodeDouble($1),
    },
    pathTranslation: switch (json['pathTranslation']) {
      null => BackendRule_PathTranslation.$default,
      Object $1 => BackendRule_PathTranslation.fromJson($1),
    },
    jwtAudience: switch (json['jwtAudience']) {
      null => null,
      Object $1 => decodeString($1),
    },
    disableAuth: switch (json['disableAuth']) {
      null => null,
      Object $1 => decodeBool($1),
    },
    protocol: switch (json['protocol']) {
      null => '',
      Object $1 => decodeString($1),
    },
    overridesByRequestProtocol: switch (json['overridesByRequestProtocol']) {
      null => {},
      Map<String, Object?> $1 => {
        for (final e in $1.entries)
          decodeString(e.key): BackendRule.fromJson(e.value),
      },
      _ => throw const FormatException(
        '"overridesByRequestProtocol" is not an object',
      ),
    },
  );
}