We are developing an Atlassian Confluence plugin (starting with RefApp, because it is a lighter app to develop on) using the Atlassian REST API plugin module (atlas-create-refapp-plugin-module, option 7 or atlas-create-confluence-plugin-module, option 9). (The front-end is Angular, so we are relying on the Rest API for the whole app.)
I need to customize the Jackson ObjectMapper. Here are two related Atlassian Community posts that are unanswered/only partially answered:
https://community.developer.atlassian.com/t/can-i-customize-the-jackson-objectmapper/31069
Here is what I want access to:
Jackson Serialization Features:
https://github.com/FasterXML/jackson-databind/wiki/Serialization-Features
Jackson Deserialization Features:
https://github.com/FasterXML/jackson-databind/wiki/Deserialization-Features
I have dug through the code of Atlassian's REST API module:
How do I override Atlassian's instantiation of ObjectMapper and register it with the appropriate modules so that I can use my own Jackson ObjectMapper settings?
Just add Jackson as dependency and use it directly.
(Please note: don't let Bandana serialize your objects, use your own mapper then. Avoids many problems…)
pom.xml
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<!-- Jackson 2.15.0 may break with older Java -> test again, when with > 2.15.0 -->
<version>2.14.2</version>
</dependency>
Code
ObjectMapper objectMapper = new ObjectMapper();
This approach works when consuming raw JSON string, but how to customize Jackson SerializationFeature or ObjectMapper visibility settings when objects jet serialized under the hood on javax.ws.rs when passing data to javax.ws.rs.core.Response?
Easyish way to work around this to to have toJson() methods on every class that needs custom serialization and call that instead of relying on the ObjectMapper under the hood but this just feels wrong. There got to be a better way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is just amazing how all the nitty-gritty questions are left unanswered.
I just consume the raw JSON string in my method and call my own object mapper.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.