ClassifyTextResponse.fromJson constructor

ClassifyTextResponse.fromJson(
  1. Object? j
)

Implementation

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