Class JacksonUtils
java.lang.Object
uno.anahata.ai.internal.JacksonUtils
A generic utility class for Jackson-based JSON operations.
This class uses the centrally configured ObjectMapper from
SchemaProvider to ensure consistency in how Java objects are
mapped to JSON across the application, especially for tool parameters
and responses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TconvertValue(Object object, Type type) Deserializes a generic object (typically a Map or List of Maps) back into a specific type, including complex generic types.static ObjectConverts any object into its JSON-safe equivalent (Map, List, or Primitive) using the centrally configured ObjectMapper.static <T> TConverts a JSON-safe object (Map, List, or Primitive) back into a rich Java object of the specified type.
-
Constructor Details
-
JacksonUtils
public JacksonUtils()
-
-
Method Details
-
toJsonPrimitives
Converts any object into its JSON-safe equivalent (Map, List, or Primitive) using the centrally configured ObjectMapper. This ensures that all POJOs are flattened and custom serializers (like ElementHandleModule) are applied.- Parameters:
o- The object to convert.- Returns:
- The JSON-safe representation of the object.
-
toPojo
Converts a JSON-safe object (Map, List, or Primitive) back into a rich Java object of the specified type.- Type Parameters:
T- The target type.- Parameters:
object- The JSON-safe object to convert.type- The target type.- Returns:
- An instance of the target type.
-
convertValue
Deserializes a generic object (typically a Map or List of Maps) back into a specific type, including complex generic types.- Type Parameters:
T- The target type.- Parameters:
object- The object to convert (typically a Map or List of Maps).type- The target type, which can be aClassor aParameterizedType.- Returns:
- An instance of the target type, or
nullif the input object is null.
-
