JacksonDataFormatConfigurator: Ability to set a ObjectMapper on a ObjectValue configuration

given

ObjectValue customerDataValue = Variables.objectValue(customerData)
  .serializationDataFormat(Variables.SerializationDataFormats.JSON)
  .create();

would be great if we could set a callback or a specific instance of a ObjectMapper when creating a ObjectValue instance?

Been looking at the JacksonDataFormatConfigurator, and the issue i see at the moment is the OM that camunda provides has many deeper configurations. And in some cases I want to use a specific OM for De/Serialization. This possible?

As another test of performance, would be interested to know the extra overhead involved if we go from object to Jackson serialize string to SPIN object to storage in Camunda. And then reverse back into the original object.

Assume you have a envelop with a type field you can use Jackson polymorphism to easily convert back and don’t need to store much extras. But the double sterilization seems to start to get expensive.

Hi Stephen,

You can configure the object mapper that Camunda BPM (via Spin) uses as described here: Configuring JSON Handling | docs.camunda.org and camunda-bpm-examples/spin/dataformat-configuration-global at master · camunda/camunda-bpm-examples · GitHub.

Cheers,
Thorben

edit:

This is not possible as you are describing it.

Is there anything special about the Camunda default objectMapper that is required for Camunda? Have people completely replaced the mapper without issues?

Doing a quick review seems to show that there is lots of customizations and configs setup in the default mapper, so trying to understand the impacts of the default mapper is completely swapped out.

Can you please give a pointer to the code that does customization? From my memory, Spin uses pretty much a default ObjectMapper instance and (de-)serialization is pretty robust with respect to custom configuration. I recommend to just try it out and write some tests to ensure that (de-)serialization still works after you have applied your configuration.

I am having an issue with this as well. I am using Spring Boot to create an ObjectMapper that I use throughout my project, and I want to reuse it in the Camunda workflows as well (specifically for date serialization).

This is what I am trying to do:

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;

import org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormat;
import org.camunda.spin.spi.DataFormatConfigurator;


public class JacksonDataFormatConfigurator implements DataFormatConfigurator<JacksonJsonDataFormat>
{
    @Autowired
    private ObjectMapper jacksonMapper;

    @Override
    public Class<JacksonJsonDataFormat> getDataFormatClass() {
        return JacksonJsonDataFormat.class;
    }

    @Override
    public void configure(JacksonJsonDataFormat dataFormat) {
//        spinjar.com.fasterxml.jackson.databind.ObjectMapper mapper = new spinjar.com.fasterxml.jackson.databind.ObjectMapper();
        dataFormat.setObjectMapper(jacksonMapper);
    }
}

However, I am getting a compiler error saying that the ObjectMapper needs to be of this type: spinjar.com.fasterxml.jackson.databind.ObjectMapper.

I have found a supposed fix for this issue here: https://github.com/camunda/camunda-docs-manual/issues/83

However, it’s not clearing my problem. I have used STS pom dependency viewer and confirmed that there are no other jars bringing in the packages.

I’m using Camunda 7.9.3-ee and Spin 1.5.3.

I am facing the same issue. I have a customized ObjectMapper already loaded as a Spring Bean and while providing JacksonDataFormatConfigurator, its complaining about the type of ObjectMapper package.

I am supposed to enable a feature but its not as simple as Spring is :slight_smile: