GenerateContentResponse.fromJson constructor

GenerateContentResponse.fromJson(
  1. Object? j
)

Implementation

factory GenerateContentResponse.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return GenerateContentResponse(
    candidates: switch (json['candidates']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) Candidate.fromJson(i)],
      _ => throw const FormatException('"candidates" is not a list'),
    },
    promptFeedback: switch (json['promptFeedback']) {
      null => null,
      Object $1 => GenerateContentResponse_PromptFeedback.fromJson($1),
    },
    usageMetadata: switch (json['usageMetadata']) {
      null => null,
      Object $1 => GenerateContentResponse_UsageMetadata.fromJson($1),
    },
    modelVersion: switch (json['modelVersion']) {
      null => '',
      Object $1 => decodeString($1),
    },
    responseId: switch (json['responseId']) {
      null => '',
      Object $1 => decodeString($1),
    },
  );
}