Skip to content

Commit

Permalink
Automatically register available Jackson modules
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-krecan committed Aug 23, 2021
1 parent 95d92d9 commit de5c908
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,15 @@ public String toString() {
private static class DefaultObjectMapperProvider implements Jackson2ObjectMapperProvider {
static final Jackson2ObjectMapperProvider INSTANCE = new DefaultObjectMapperProvider();

private static final ObjectMapper mapper = new ObjectMapper();
private static final ObjectMapper lenientMapper = new ObjectMapper();
private static final ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
private static final ObjectMapper lenientMapper = new ObjectMapper().findAndRegisterModules();

static {
lenientMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
lenientMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
lenientMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
}

@Override
public ObjectMapper getObjectMapper(boolean lenient) {
return lenient ? lenientMapper : mapper;
Expand Down

0 comments on commit de5c908

Please sign in to comment.