-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-10058: Introduce Jackson 3 in the Gradle build #10158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Related to: spring-projects#10058 * Add `jackson3Version` variable and BOM import * Include Jackson 3 dependencies across modules Signed-off-by: Jooyoung Pyoung <[email protected]>
Thank you, @anthologia , for looking into this! |
@@ -497,6 +500,11 @@ project('spring-integration-core') { | |||
api 'io.projectreactor:reactor-core' | |||
api 'io.micrometer:micrometer-observation' | |||
|
|||
optionalApi 'tools.jackson.core:jackson-databind' | |||
optionalApi 'tools.jackson.datatype:jackson-datatype-joda' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not familiar with Jackson 3 and how it manages time API, but is Joda still a thing?
From where did you take this dependencies arrangement ?
Why there are no more for time, for example and parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Jackson 3, "parameter names" and "datatypes" modules are now built-in.
JSTEP documentation: https://github.com/FasterXML/jackson-future-ideas/wiki/Jackson3-Changes#maven-modules-jars-java-packages
For Joda, I added it by referencing our Jackson2JsonObjectMapper
. I tested it as shown below, and without adding JodaModule
, Joda couldn't be supported.
public static class JodaData {
public String name;
public org.joda.time.DateTime createdAt;
public JodaData(String name, DateTime createdAt) {
this.name = name;
this.createdAt = createdAt;
}
}
@Test
@DisplayName("[Jackson3] With JodaModule")
public void testJackson3JodaSerializationWithJodaModule() throws Exception {
tools.jackson.databind.ObjectMapper mapper = JsonMapper.builder()
.addModule(new JodaModule())
.build();
DateTime jodaDateTime = new DateTime();
JodaData data = new JodaData("John", jodaDateTime);
String json = mapper.writeValueAsString(data);
mapper.readValue(json, JodaData.class);
System.out.println("✅ Joda works with JodaModule in Jackson 3");
}
@Test
@DisplayName("[Jackson3] Without JodaModule")
public void testJackson3JodaSerializationWithoutJodaModule() throws Exception {
tools.jackson.databind.ObjectMapper mapper = JsonMapper.builder()
.build();
DateTime jodaDateTime = new DateTime();
JodaData data = new JodaData("John", jodaDateTime);
Assert.assertThrows(tools.jackson.core.JacksonException.class, () -> mapper.writeValueAsString(data));
System.out.println("❌ Joda doesn't work without JodaModule");
}
There are many changes in default configurations and other aspects. To save our time, I'll leave review comments with references to these changes in upcoming PRs!
Thanks for the feedback! Let me clarify my approach for Work 2 and Work 3: Work 2 would implement the Jackson 3 counterparts like:
Work 3 would then use these new components in places like if (JacksonPresent.isJackson3Present()) { // here
ObjectMapper objectMapper = new Jackson3JsonObjectMapper().getObjectMapper(); // here
JacksonJsonMessageConverter jacksonJsonMessageConverter = new JacksonJsonMessageConverter(objectMapper);
// ...
} |
Thanks for clarification! |
Related to: #10058
First part of the Jackson 3 support implementation for issue. I've split this work for easier review and management:
Does this approach work for you?