MetricRule.fromJson constructor

MetricRule.fromJson(
  1. Object? j
)

Implementation

factory MetricRule.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return MetricRule(
    selector: switch (json['selector']) {
      null => '',
      Object $1 => decodeString($1),
    },
    metricCosts: switch (json['metricCosts']) {
      null => {},
      Map<String, Object?> $1 => {
        for (final e in $1.entries) decodeString(e.key): decodeInt64(e.value),
      },
      _ => throw const FormatException('"metricCosts" is not an object'),
    },
  );
}