Spring Boot and Spin Json serialization - Jackson annotations are not working

I’m using Camunda Spring Boot 2.2.0 and Json serialization with Spin. But my Jackson annotations are not supported during serialization and deserialization.

Example of not workring annotation: com.fasterxml.jackson.annotation.JsonIgnore

I also tried to configure existing objectMapper in my configuration implementing DataFormatConfigurator but no success.

@Override
public void configure(JacksonJsonDataFormat dataFormat) {
	spinjar.com.fasterxml.jackson.databind.ObjectMapper objectMapper = dataFormat.getObjectMapper();
	objectMapper.configure(MapperFeature.USE_ANNOTATIONS, true);
}

I found that maybe it’s a problem that I’m using dependency: camunda-spin-dataformat-all (see: Missing Jackson annotation support in Camunda Spin). Solution is to use camunda-spin-dataformat-json-jackson.

But if I’m using camunda-spin-dataformat-json-jackson then JSON serialization is not working at all and “x-java-serialized-object” is used.

I can’t change POJO which I need to serialize as process variable because I have it as a dependency.

I craeted a small test. First object mapper is accepting Jackson annotations that second (spin) doesn’t:

// OK
com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper();
String writeValueAsString = om.writeValueAsString(validationResult);

// NOT OK
spinjar.com.fasterxml.jackson.databind.ObjectMapper om2 = new spinjar.com.fasterxml.jackson.databind.ObjectMapper();
String writeValueAsString2 = om2.writeValueAsString(validationResult);

I found another topics about spin but no solution for me:

1:
https://groups.google.com/forum/#!topic/camunda-bpm-users/7lmaGZKk9K4

2:

My mistake, camunda spring boot starter is working with dependency camunda-spin-dataformat-json-jackson.

Solution for me was: remove dependency camunda-spin-dataformat-all and use camunda-spin-dataformat-json-jackson (as described in link 1). Jackson annotations in POJOs are working.

1 Like