Class GsonUtils

java.lang.Object
uno.anahata.ai.internal.GsonUtils

public final class GsonUtils extends Object
Utility class for GSON-based JSON operations.

This class provides a centrally configured Gson instance that correctly handles Java 8 Optional types, which are extensively used in the Google GenAI library.

  • Constructor Details

    • GsonUtils

      public GsonUtils()
  • Method Details

    • getGson

      public static com.google.gson.Gson getGson()
      Gets the default, compact GSON instance.
      Returns:
      The GSON instance.
    • prettyPrint

      public static String prettyPrint(Object value)
      Pretty prints an object to a JSON string. If the object is a string that is not a valid JSON, it returns the original string.
      Parameters:
      value - The object to pretty print.
      Returns:
      The pretty printed JSON string or the original string.