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