Skip to content

Commit

Permalink
Refine scope of Jackson module registration
Browse files Browse the repository at this point in the history
  • Loading branch information
maple-buice committed Dec 11, 2023
1 parent c2fdd0c commit 28b524b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/java/com/hubspot/jinjava/JinjavaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.google.common.collect.ImmutableSet;
import com.hubspot.jinjava.el.JinjavaInterpreterResolver;
import com.hubspot.jinjava.el.JinjavaObjectUnwrapper;
Expand Down Expand Up @@ -158,8 +157,7 @@ private JinjavaConfig(Builder builder) {

private ObjectMapper setupObjectMapper(@Nullable ObjectMapper objectMapper) {
if (objectMapper == null) {
objectMapper = new ObjectMapper().registerModule(new JavaTimeModule());

objectMapper = new ObjectMapper();
if (legacyOverrides.isUseSnakeCasePropertyNaming()) {
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hubspot.jinjava.lib.filter;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.hubspot.jinjava.doc.annotations.JinjavaDoc;
import com.hubspot.jinjava.doc.annotations.JinjavaParam;
import com.hubspot.jinjava.doc.annotations.JinjavaSnippet;
Expand Down Expand Up @@ -55,6 +56,7 @@ public Object filter(Object var, JinjavaInterpreter interpreter, String... args)
interpreter
.getConfig()
.getObjectMapper()
.registerModule(new JavaTimeModule())
.writerWithDefaultPrettyPrinter()
.writeValueAsString(var);
} catch (JsonProcessingException e) {
Expand Down

0 comments on commit 28b524b

Please sign in to comment.