SafetyRating.fromJson constructor

SafetyRating.fromJson(
  1. Object? j
)

Implementation

factory SafetyRating.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return SafetyRating(
    category: switch (json['category']) {
      null => HarmCategory.$default,
      Object $1 => HarmCategory.fromJson($1),
    },
    probability: switch (json['probability']) {
      null => SafetyRating_HarmProbability.$default,
      Object $1 => SafetyRating_HarmProbability.fromJson($1),
    },
    probabilityScore: switch (json['probabilityScore']) {
      null => 0,
      Object $1 => decodeDouble($1),
    },
    severity: switch (json['severity']) {
      null => SafetyRating_HarmSeverity.$default,
      Object $1 => SafetyRating_HarmSeverity.fromJson($1),
    },
    severityScore: switch (json['severityScore']) {
      null => 0,
      Object $1 => decodeDouble($1),
    },
    blocked: switch (json['blocked']) {
      null => false,
      Object $1 => decodeBool($1),
    },
  );
}