Class JsonSerializable

java.lang.Object
com.google.genai.JsonSerializable
Direct Known Subclasses:
Blob, Candidate, Citation, CitationMetadata, CodeExecutionResult, Content, ControlReferenceConfig, ControlReferenceImage, DynamicRetrievalConfig, ExecutableCode, FileData, FunctionCall, FunctionCallingConfig, FunctionDeclaration, FunctionResponse, GenerateContentConfig, GenerateContentParameters, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GeneratedImage, GenerateImagesConfig, GenerateImagesParameters, GenerateImagesResponse, GenerationConfig, GenerationConfigRoutingConfig, GenerationConfigRoutingConfigAutoRoutingMode, GenerationConfigRoutingConfigManualRoutingMode, GoogleSearch, GoogleSearchRetrieval, GoogleTypeDate, GroundingChunk, GroundingChunkRetrievedContext, GroundingChunkWeb, GroundingMetadata, GroundingSupport, HttpOptions, Image, LogprobsResult, LogprobsResultCandidate, LogprobsResultTopCandidates, MaskReferenceConfig, MaskReferenceImage, Part, PrebuiltVoiceConfig, RawReferenceImage, ReplayFile, ReplayInteraction, ReplayRequest, ReplayResponse, Retrieval, RetrievalMetadata, SafetyRating, SafetySetting, Schema, SearchEntryPoint, Segment, SpeechConfig, StyleReferenceConfig, StyleReferenceImage, SubjectReferenceConfig, SubjectReferenceImage, TestTableFile, TestTableItem, ThinkingConfig, Tool, ToolCodeExecution, ToolConfig, UploadFileConfig, UpscaleImageAPIConfig, UpscaleImageAPIParameters, UpscaleImageConfig, UpscaleImageParameters, UpscaleImageResponse, VertexAISearch, VertexRagStore, VertexRagStoreRagResource, VideoMetadata, VoiceConfig

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

    • objectMapper

      protected static final com.fasterxml.jackson.databind.ObjectMapper objectMapper
  • Constructor Details

    • JsonSerializable

      public JsonSerializable()
  • Method Details

    • toJsonString

      protected static String toJsonString(Object object)
      Serializes an object to a Json string.
    • toJson

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

      protected static com.fasterxml.jackson.databind.JsonNode toJsonNode(Object object)
      Serializes an object to a JsonNode.
    • fromJsonString

      public static <T extends JsonSerializable> T fromJsonString(String jsonString, Class<T> clazz)
      Deserializes a Json string to an object of the given type.
    • fromJsonNode

      public static <T extends JsonSerializable> T fromJsonNode(com.fasterxml.jackson.databind.JsonNode jsonNode, Class<T> clazz)
      Deserializes a JsonNode to an object of the given type.