Hi folks,
I’m trying to configure jackson to serialize java.time.Instant as a string (“2022-02-16T10:56:57.097944Z”) instead of a timestamp.
As the documentation mentioned I implemented a configuration class:
public class JacksonDataFormatConfigurator implements DataFormatConfigurator<JacksonJsonDataFormat> {
public void configure(JacksonJsonDataFormat dataFormat) {
ObjectMapper objectMapper = dataFormat.getObjectMapper();
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
public Class<JacksonJsonDataFormat> getDataFormatClass() {
return JacksonJsonDataFormat.class;
}
}
and specified it in the file: src/main/resources/META-INF/services/org.camunda.spin.spi.DataFormatConfigurator
com.easydoc.bpm.config.JacksonDataFormatConfigurator
Now I see proper serialized variable value in Cockpit:
But when I’m trying to get the variable value via REST API, it still serialized as a timestamp
GET http://localhost:8080/engine-rest/task/29428d9f-8f17-11ec-8b23-ee2497a1ef63/form-variables
{
"dto": {
"type": "Object",
"value": {
"createDate": {
"nano": 97944000,
"epochSecond": 1645009017
},
"description": "TEST"
},
"valueInfo": {
"objectTypeName": "com.sandbox.bpm.instant.TestDto",
"serializationDataFormat": "application/json"
}
}
}
Environment configuration:
Camunda BPM v. 7.16, Embedded Engine (Spring Boot v. 2.5.4).
camunda.bpm.default-serialization-format: application/json
pom.xml (jackson/Spin related dependencies, others omitted)
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-plugin-spin</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.spin</groupId>
<artifactId>camunda-spin-dataformat-json-jackson</artifactId>
</dependency>
Any help would be appreciated
WBR, Slava