Distribution.fromJson constructor

Distribution.fromJson(
  1. Object? j
)

Implementation

factory Distribution.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return Distribution(
    count: switch (json['count']) {
      null => 0,
      Object $1 => decodeInt64($1),
    },
    mean: switch (json['mean']) {
      null => 0,
      Object $1 => decodeDouble($1),
    },
    sumOfSquaredDeviation: switch (json['sumOfSquaredDeviation']) {
      null => 0,
      Object $1 => decodeDouble($1),
    },
    range: switch (json['range']) {
      null => null,
      Object $1 => Distribution_Range.fromJson($1),
    },
    bucketOptions: switch (json['bucketOptions']) {
      null => null,
      Object $1 => Distribution_BucketOptions.fromJson($1),
    },
    bucketCounts: switch (json['bucketCounts']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeInt64(i)],
      _ => throw const FormatException('"bucketCounts" is not a list'),
    },
    exemplars: switch (json['exemplars']) {
      null => [],
      List<Object?> $1 => [
        for (final i in $1) Distribution_Exemplar.fromJson(i),
      ],
      _ => throw const FormatException('"exemplars" is not a list'),
    },
  );
}