AnalyzeSentimentResponse.fromJson constructor

AnalyzeSentimentResponse.fromJson(
  1. Object? j
)

Implementation

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