Class JacksonJsonPayloadConverter

java.lang.Object
io.temporal.common.converter.JacksonJsonPayloadConverter
All Implemented Interfaces:
PayloadConverter

public class JacksonJsonPayloadConverter extends Object implements PayloadConverter
  • Constructor Details

    • JacksonJsonPayloadConverter

      public JacksonJsonPayloadConverter()
    • JacksonJsonPayloadConverter

      public JacksonJsonPayloadConverter(com.fasterxml.jackson.databind.ObjectMapper mapper)
  • Method Details

    • setDefaultAsJackson3

      @Experimental public static void setDefaultAsJackson3(boolean defaultAsJackson3, boolean jackson2Compat)
      Opts in to or out of using Jackson 3.x as the default JSON payload converter. When enabled, instances created via the default constructor will delegate all serialization/deserialization to a Jackson3JsonPayloadConverter.

      This applies globally, including to the converter in DefaultDataConverter.STANDARD_PAYLOAD_CONVERTERS. Call this method early in your application, before creating any Temporal clients.

      Requires Java 17+ and tools.jackson.core:jackson-databind:3.x on the classpath.

      Parameters:
      defaultAsJackson3 - true to delegate to Jackson 3, false to revert to Jackson 2
      jackson2Compat - if true, the Jackson 3 converter is configured with Jackson 2.x default behaviors for maximum wire compatibility. If false, Jackson 3.x native defaults are used. Only relevant when defaultAsJackson3 is true.
      Throws:
      IllegalStateException - if Jackson 3 is not available
      See Also:
    • newDefaultObjectMapper

      public static com.fasterxml.jackson.databind.ObjectMapper newDefaultObjectMapper()
      Can be used as a starting point for custom user configurations of ObjectMapper.
      Returns:
      a default configuration of ObjectMapper used by JacksonJsonPayloadConverter.
    • getEncodingType

      public String getEncodingType()
      Description copied from interface: PayloadConverter
      Each PayloadConverter has an Encoding Type that it handles. Each PayloadConverter should add the information about its Encoding Type into the Payload it produces inside PayloadConverter.toData(Object) by associating it with the EncodingKeys.METADATA_ENCODING_KEY key attached to the Payload's Metadata using Payload.Builder.putMetadata(String, ByteString).
      Specified by:
      getEncodingType in interface PayloadConverter
      Returns:
      encoding type that this converter handles.
    • toData

      public Optional<io.temporal.api.common.v1.Payload> toData(Object value) throws DataConverterException
      Description copied from interface: PayloadConverter
      Implements conversion of a list of values.
      Specified by:
      toData in interface PayloadConverter
      Parameters:
      value - Java value to convert.
      Returns:
      converted value
      Throws:
      DataConverterException - if conversion of the value passed as parameter failed for any reason.
      See Also:
    • fromData

      public <T> T fromData(io.temporal.api.common.v1.Payload content, Class<T> valueClass, Type valueType) throws DataConverterException
      Description copied from interface: PayloadConverter
      Implements conversion of a single value.
      Specified by:
      fromData in interface PayloadConverter
      Parameters:
      content - Serialized value to convert to a Java object.
      valueClass - type of the value stored in the content
      valueType - generic type of the value stored in the content
      Returns:
      converted Java object
      Throws:
      DataConverterException - if conversion of the data passed as parameter failed for any reason.