Class EmptyObjectTolerantListDeserializer

java.lang.Object
tools.jackson.databind.ValueDeserializer<List<?>>
io.jmix.aitools.dataload.json.EmptyObjectTolerantListDeserializer
All Implemented Interfaces:
tools.jackson.databind.deser.NullValueProvider

@NullMarked public class EmptyObjectTolerantListDeserializer extends tools.jackson.databind.ValueDeserializer<List<?>>
Jackson deserializer for a List field that tolerates LLM output emitting an empty JSON object ({}) where a JSON array is expected, mapping it to an empty list.

Small local models non-deterministically render an empty list (such as a parameterless query's parameters) as {} instead of []. Because the tolerance is attached to the target field via @JsonDeserialize, it applies regardless of which ObjectMapper performs the binding — including the mapper Spring AI uses internally to bind tool-call arguments, which cannot be configured externally.

Only an empty object is coerced; a non-empty object where an array is expected is left to be reported as a genuine mismatch. Non-object values are delegated to the standard list deserialization, so populated arrays are unaffected.

  • Nested Class Summary

    Nested classes/interfaces inherited from class tools.jackson.databind.ValueDeserializer

    tools.jackson.databind.ValueDeserializer.None
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final @Nullable tools.jackson.databind.JavaType
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
     
    protected
    EmptyObjectTolerantListDeserializer(@Nullable tools.jackson.databind.JavaType listType)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    tools.jackson.databind.ValueDeserializer<?>
    createContextual(tools.jackson.databind.DeserializationContext ctxt, @Nullable tools.jackson.databind.BeanProperty property)
     
    List<?>
    deserialize(tools.jackson.core.JsonParser p, tools.jackson.databind.DeserializationContext ctxt)
     
    protected tools.jackson.databind.JavaType
    resolveListType(tools.jackson.databind.DeserializationContext ctxt)
     

    Methods inherited from class tools.jackson.databind.ValueDeserializer

    collectAllPropertyNamesTo, deserialize, deserializeWithType, deserializeWithType, findBackReference, getAbsentValue, getDelegatee, getEmptyAccessPattern, getEmptyValue, getKnownPropertyNames, getNullAccessPattern, getNullValue, getObjectIdReader, handledType, hasAnySetter, isCachable, logicalType, replaceDelegatee, resolve, supportsUpdate, unwrappingDeserializer

    Methods inherited from class java.lang.Object

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

    • listType

      protected final @Nullable tools.jackson.databind.JavaType listType
  • Constructor Details

    • EmptyObjectTolerantListDeserializer

      public EmptyObjectTolerantListDeserializer()
    • EmptyObjectTolerantListDeserializer

      protected EmptyObjectTolerantListDeserializer(@Nullable tools.jackson.databind.JavaType listType)
  • Method Details

    • createContextual

      public tools.jackson.databind.ValueDeserializer<?> createContextual(tools.jackson.databind.DeserializationContext ctxt, @Nullable tools.jackson.databind.BeanProperty property)
      Overrides:
      createContextual in class tools.jackson.databind.ValueDeserializer<List<?>>
    • deserialize

      public List<?> deserialize(tools.jackson.core.JsonParser p, tools.jackson.databind.DeserializationContext ctxt)
      Specified by:
      deserialize in class tools.jackson.databind.ValueDeserializer<List<?>>
    • resolveListType

      protected tools.jackson.databind.JavaType resolveListType(tools.jackson.databind.DeserializationContext ctxt)