Class JsonSerializable

java.lang.Object
com.google.genai.JsonSerializable
Direct Known Subclasses:
ActivityEnd, ActivityStart, ApiAuth, ApiAuthApiKeyConfig, ApiKeyConfig, AudioTranscriptionConfig, AuthConfig, AuthConfigGoogleServiceAccountConfig, AuthConfigHttpBasicAuthConfig, AuthConfigOauthConfig, AuthConfigOidcConfig, AutomaticActivityDetection, AutomaticFunctionCallingConfig, AutoraterConfig, BatchJob, BatchJobDestination, BatchJobSource, Blob, CachedContent, CachedContentUsageMetadata, CancelBatchJobConfig, CancelBatchJobParameters, CancelTuningJobConfig, CancelTuningJobParameters, Candidate, Checkpoint, ChunkingConfig, Citation, CitationMetadata, ClientOptions, CodeExecutionResult, CompletionStats, ComputerUse, ComputeTokensConfig, ComputeTokensParameters, ComputeTokensResponse, ComputeTokensResult, Content, ContentEmbedding, ContentEmbeddingStatistics, ContentReferenceImage, ContextWindowCompressionConfig, ControlReferenceConfig, ControlReferenceImage, CountTokensConfig, CountTokensParameters, CountTokensResponse, CountTokensResult, CreateBatchJobConfig, CreateBatchJobParameters, CreateCachedContentConfig, CreateCachedContentParameters, CreateEmbeddingsBatchJobConfig, CreateEmbeddingsBatchJobParameters, CreateFileConfig, CreateFileParameters, CreateFileResponse, CreateFileSearchStoreConfig, CreateFileSearchStoreParameters, CreateTuningJobConfig, CreateTuningJobParameters, CreateTuningJobParametersPrivate, CustomMetadata, DatasetDistribution, DatasetDistributionDistributionBucket, DatasetStats, DeleteBatchJobConfig, DeleteBatchJobParameters, DeleteCachedContentConfig, DeleteCachedContentParameters, DeleteCachedContentResponse, DeleteDocumentConfig, DeleteDocumentParameters, DeleteFileConfig, DeleteFileParameters, DeleteFileResponse, DeleteFileSearchStoreConfig, DeleteFileSearchStoreParameters, DeleteModelConfig, DeleteModelParameters, DeleteModelResponse, DeleteResourceJob, DistillationDataStats, Document, DownloadFileConfig, DynamicRetrievalConfig, EditImageConfig, EditImageParameters, EditImageResponse, EmbedContentBatch, EmbedContentConfig, EmbedContentMetadata, EmbedContentParameters, EmbedContentResponse, EmbeddingsBatchJobSource, EncryptionSpec, Endpoint, EnterpriseWebSearch, EntityLabel, EvaluationConfig, ExecutableCode, ExternalApi, ExternalApiElasticSearchParams, ExternalApiSimpleSearchParams, FetchPredictOperationConfig, FetchPredictOperationParameters, File, FileData, FileSearch, FileSearchStore, FileStatus, FunctionCall, FunctionCallingConfig, FunctionDeclaration, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, GcsDestination, GeminiPreferenceExample, GeminiPreferenceExampleCompletion, GenerateContentConfig, GenerateContentParameters, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GeneratedImage, GeneratedImageMask, GeneratedVideo, GenerateImagesConfig, GenerateImagesParameters, GenerateImagesResponse, GenerateVideosConfig, GenerateVideosParameters, GenerateVideosResponse, GenerateVideosSource, GenerationConfig, GenerationConfigRoutingConfig, GenerationConfigRoutingConfigAutoRoutingMode, GenerationConfigRoutingConfigManualRoutingMode, GetBatchJobConfig, GetBatchJobParameters, GetCachedContentConfig, GetCachedContentParameters, GetDocumentConfig, GetDocumentParameters, GetFileConfig, GetFileParameters, GetFileSearchStoreConfig, GetFileSearchStoreParameters, GetModelConfig, GetModelParameters, GetOperationConfig, GetOperationParameters, GetTuningJobConfig, GetTuningJobParameters, GoogleMaps, GoogleRpcStatus, GoogleSearch, GoogleSearchRetrieval, GoogleTypeDate, GroundingChunk, GroundingChunkMaps, GroundingChunkMapsPlaceAnswerSources, GroundingChunkMapsPlaceAnswerSourcesAuthorAttribution, GroundingChunkMapsPlaceAnswerSourcesReviewSnippet, GroundingChunkRetrievedContext, GroundingChunkWeb, GroundingMetadata, GroundingMetadataSourceFlaggingUri, GroundingSupport, HttpOptions, HttpResponse, HttpRetryOptions, Image, ImageConfig, ImportFileConfig, ImportFileParameters, ImportFileResponse, InlinedEmbedContentResponse, InlinedRequest, InlinedResponse, Interval, JobError, LatLng, ListBatchJobsConfig, ListBatchJobsParameters, ListBatchJobsResponse, ListCachedContentsConfig, ListCachedContentsParameters, ListCachedContentsResponse, ListDocumentsConfig, ListDocumentsParameters, ListDocumentsResponse, ListFilesConfig, ListFileSearchStoresConfig, ListFileSearchStoresParameters, ListFileSearchStoresResponse, ListFilesParameters, ListFilesResponse, ListModelsConfig, ListModelsParameters, ListModelsResponse, ListTuningJobsConfig, ListTuningJobsParameters, ListTuningJobsResponse, LiveClientContent, LiveClientMessage, LiveClientRealtimeInput, LiveClientSetup, LiveClientToolResponse, LiveConnectConfig, LiveConnectParameters, LiveSendClientContentParameters, LiveSendRealtimeInputParameters, LiveSendToolResponseParameters, LiveServerContent, LiveServerGoAway, LiveServerMessage, LiveServerSessionResumptionUpdate, LiveServerSetupComplete, LiveServerToolCall, LiveServerToolCallCancellation, LogprobsResult, LogprobsResultCandidate, LogprobsResultTopCandidates, MaskReferenceConfig, MaskReferenceImage, Metric, ModalityTokenCount, Model, ModelSelectionConfig, MultiSpeakerVoiceConfig, Operation, OutputConfig, Part, PartialArg, PartMediaResolution, PartnerModelTuningSpec, PrebuiltVoiceConfig, PreferenceOptimizationDataStats, PreferenceOptimizationHyperParameters, PreferenceOptimizationSpec, PreTunedModel, ProactivityConfig, ProductImage, RagChunk, RagChunkPageSpan, RagRetrievalConfig, RagRetrievalConfigFilter, RagRetrievalConfigHybridSearch, RagRetrievalConfigRanking, RagRetrievalConfigRankingLlmRanker, RagRetrievalConfigRankingRankService, RawReferenceImage, RealtimeInputConfig, RecontextImageConfig, RecontextImageParameters, RecontextImageResponse, RecontextImageSource, ReferenceImageAPI, ReplayFile, ReplayInteraction, ReplayRequest, ReplayResponse, Retrieval, RetrievalConfig, RetrievalMetadata, SafetyAttributes, SafetyRating, SafetySetting, Schema, ScribbleImage, SearchEntryPoint, Segment, SegmentImageConfig, SegmentImageParameters, SegmentImageResponse, SegmentImageSource, SessionResumptionConfig, SingleEmbedContentResponse, SlidingWindow, SpeakerVoiceConfig, SpeechConfig, StringList, StyleReferenceConfig, StyleReferenceImage, SubjectReferenceConfig, SubjectReferenceImage, SupervisedHyperParameters, SupervisedTuningDatasetDistribution, SupervisedTuningDatasetDistributionDatasetBucket, SupervisedTuningDataStats, SupervisedTuningSpec, TestTableFile, TestTableItem, ThinkingConfig, TokensInfo, Tool, ToolCodeExecution, ToolConfig, Transcription, TunedModel, TunedModelCheckpoint, TunedModelInfo, TuningDataset, TuningDataStats, TuningExample, TuningJob, TuningOperation, TuningValidationDataset, UpdateCachedContentConfig, UpdateCachedContentParameters, UpdateModelConfig, UpdateModelParameters, UploadFileConfig, UploadToFileSearchStoreConfig, UploadToFileSearchStoreParameters, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageAPIConfig, UpscaleImageAPIParameters, UpscaleImageConfig, UpscaleImageParameters, UpscaleImageResponse, UrlContext, UrlContextMetadata, UrlMetadata, UsageMetadata, VeoHyperParameters, VeoTuningSpec, VertexAISearch, VertexAISearchDataStoreSpec, VertexRagStore, VertexRagStoreRagResource, Video, VideoGenerationMask, VideoGenerationReferenceImage, VideoMetadata, VoiceConfig, WhiteSpaceConfig

public abstract class JsonSerializable extends Object
A class that can be serialized to JSON and deserialized from JSON.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    System property to override the default max JSON string length (20MB) in read constraints.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    setMaxReadLength(int maxReadLength)
    Overrides the default maximum JSON string length (20MB) for the JSON parser.
    static com.fasterxml.jackson.databind.JsonNode
    Converts a Json string to a JsonNode.
    Serializes the instance to a Json string.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_READ_LENGTH_PROPERTY

      public static final String MAX_READ_LENGTH_PROPERTY
      System property to override the default max JSON string length (20MB) in read constraints. E.g., if you want to change the limit to 100MB, you can set it via `-Dgenai.json.maxReadLength=100000000`.
      See Also:
  • Constructor Details

    • JsonSerializable

      public JsonSerializable()
  • Method Details

    • toJson

      public String toJson()
      Serializes the instance to a Json string.
    • stringToJsonNode

      public static com.fasterxml.jackson.databind.JsonNode stringToJsonNode(String string)
      Converts a Json string to a JsonNode.
    • setMaxReadLength

      public static void setMaxReadLength(int maxReadLength)
      Overrides the default maximum JSON string length (20MB) for the JSON parser.

      Warning: This modifies a global static setting. It will overrides the system property setting via MAX_READ_LENGTH_PROPERTY. This method is not thread-safe.

      Parameters:
      maxReadLength - the new maximum string length in bytes (e.g., 100_000_000 for 100MB).