ModerateTextResponse.fromJson constructor

ModerateTextResponse.fromJson(
  1. Object? j
)

Implementation

factory ModerateTextResponse.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return ModerateTextResponse(
    moderationCategories: switch (json['moderationCategories']) {
      null => [],
      List<Object?> $1 => [
        for (final i in $1) ClassificationCategory.fromJson(i),
      ],
      _ => throw const FormatException(
        '"moderationCategories" is not a list',
      ),
    },
    languageCode: switch (json['languageCode']) {
      null => '',
      Object $1 => decodeString($1),
    },
    languageSupported: switch (json['languageSupported']) {
      null => false,
      Object $1 => decodeBool($1),
    },
  );
}