Spring Boot Object mapper
See original GitHub issueHello,
I there any possibility to share Jackson Object Mapper between Spring Boot and GraphQL?
Instead of duplicating code like this
GraphQL
@Component
public class GraphQlObjectMapperConfigurer implements ObjectMapperConfigurer {
@Override
public void configure(ObjectMapper mapper, ObjectMapperConfigurerContext context) {
mapper.registerModule(new JavaTimeModule())
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}
}
Spring Boot
@Configuration
public class JacksonConfiguration {
@Bean
Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
JavaTimeModule module = new JavaTimeModule();
return new Jackson2ObjectMapperBuilder()
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.serializationInclusion(JsonInclude.Include.NON_NULL)
.findModulesViaServiceLoader(true)
.modulesToInstall(module);
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Spring Boot: Customize the Jackson ObjectMapper - Baeldung
When using JSON format, Spring Boot will use an ObjectMapper instance to serialize responses and deserialize requests. In this tutorial, we'll take a...
Read more >Spring Boot - Customize the Jackson ObjectMapper
When using JSON format, Spring Boot will use an ObjectMapper instance to serialize responses and deserialize requests.
Read more >Configuring ObjectMapper in Spring - java - Stack Overflow
A question: you must name the class JacksonConfiguration ? It's an automagical way to instruct Spring Boot to use this class as configuration ......
Read more >Jackson ObjectMapper Tutorial - Apps Developer Blog
In this tutorial, you will learn how to use Jackson ObjectMapper with Spring Boot application to serialize and deserialize Java objects.
Read more >Creating a springboot CRUD api Using the Jackson ... - Medium
Note that in the create method we receive ProductEntity as our RequestBody(JSON) and let the Jackson.ObjectMapper deserializes it into our POJO. now we...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think by default you would expect spring’s default object mapper but I also understand that you may want to configure it differently. Could you add some property like
...graphql.use-default-objectmapper = false
and then provide a objectmapper with a certain qualifier?Cool!