GenerateContentResponse_UsageMetadata.fromJson constructor
GenerateContentResponse_UsageMetadata.fromJson(
- Object? j
Implementation
factory GenerateContentResponse_UsageMetadata.fromJson(Object? j) {
final json = j as Map<String, Object?>;
return GenerateContentResponse_UsageMetadata(
promptTokenCount: switch (json['promptTokenCount']) {
null => 0,
Object $1 => decodeInt($1),
},
cachedContentTokenCount: switch (json['cachedContentTokenCount']) {
null => 0,
Object $1 => decodeInt($1),
},
candidatesTokenCount: switch (json['candidatesTokenCount']) {
null => 0,
Object $1 => decodeInt($1),
},
toolUsePromptTokenCount: switch (json['toolUsePromptTokenCount']) {
null => 0,
Object $1 => decodeInt($1),
},
thoughtsTokenCount: switch (json['thoughtsTokenCount']) {
null => 0,
Object $1 => decodeInt($1),
},
totalTokenCount: switch (json['totalTokenCount']) {
null => 0,
Object $1 => decodeInt($1),
},
promptTokensDetails: switch (json['promptTokensDetails']) {
null => [],
List<Object?> $1 => [
for (final i in $1) ModalityTokenCount.fromJson(i),
],
_ => throw const FormatException('"promptTokensDetails" is not a list'),
},
cacheTokensDetails: switch (json['cacheTokensDetails']) {
null => [],
List<Object?> $1 => [
for (final i in $1) ModalityTokenCount.fromJson(i),
],
_ => throw const FormatException('"cacheTokensDetails" is not a list'),
},
candidatesTokensDetails: switch (json['candidatesTokensDetails']) {
null => [],
List<Object?> $1 => [
for (final i in $1) ModalityTokenCount.fromJson(i),
],
_ => throw const FormatException(
'"candidatesTokensDetails" is not a list',
),
},
toolUsePromptTokensDetails: switch (json['toolUsePromptTokensDetails']) {
null => [],
List<Object?> $1 => [
for (final i in $1) ModalityTokenCount.fromJson(i),
],
_ => throw const FormatException(
'"toolUsePromptTokensDetails" is not a list',
),
},
);
}