Class JsonParser

java.lang.Object
org.springframework.ai.util.json.JsonParser

public final class JsonParser extends Object
Utilities to perform parsing operations between JSON and Java.
  • Method Details

    • getObjectMapper

      public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      Returns a Jackson ObjectMapper instance tailored for JSON-parsing operations for tool calling and structured output.
    • fromJson

      public static <T> T fromJson(String json, Class<T> type)
      Converts a JSON string to a Java object.
    • fromJson

      public static <T> T fromJson(String json, com.fasterxml.jackson.core.type.TypeReference<T> type)
      Converts a JSON string to a Java object.
    • toJson

      public static String toJson(@Nullable Object object)
      Converts a Java object to a JSON string.
    • toTypedObject

      public static Object toTypedObject(Object value, Class<?> type)
      Convert a Java Object to a typed Object. Based on the implementation in MethodInvokingFunctionCallback.