ContextRule.fromJson constructor

ContextRule.fromJson(
  1. Object? j
)

Implementation

factory ContextRule.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return ContextRule(
    selector: switch (json['selector']) {
      null => '',
      Object $1 => decodeString($1),
    },
    requested: switch (json['requested']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException('"requested" is not a list'),
    },
    provided: switch (json['provided']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException('"provided" is not a list'),
    },
    allowedRequestExtensions: switch (json['allowedRequestExtensions']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException(
        '"allowedRequestExtensions" is not a list',
      ),
    },
    allowedResponseExtensions: switch (json['allowedResponseExtensions']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException(
        '"allowedResponseExtensions" is not a list',
      ),
    },
  );
}