GroundingMetadata.fromJson constructor

GroundingMetadata.fromJson(
  1. Object? j
)

Implementation

factory GroundingMetadata.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return GroundingMetadata(
    searchEntryPoint: switch (json['searchEntryPoint']) {
      null => null,
      Object $1 => SearchEntryPoint.fromJson($1),
    },
    groundingChunks: switch (json['groundingChunks']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) GroundingChunk.fromJson(i)],
      _ => throw const FormatException('"groundingChunks" is not a list'),
    },
    groundingSupports: switch (json['groundingSupports']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) GroundingSupport.fromJson(i)],
      _ => throw const FormatException('"groundingSupports" is not a list'),
    },
    retrievalMetadata: switch (json['retrievalMetadata']) {
      null => null,
      Object $1 => RetrievalMetadata.fromJson($1),
    },
    webSearchQueries: switch (json['webSearchQueries']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) decodeString(i)],
      _ => throw const FormatException('"webSearchQueries" is not a list'),
    },
  );
}