Skip to content

Instantly share code, notes, and snippets.

@toandv
Created March 25, 2016 03:55
Show Gist options
  • Save toandv/beb3febd6e5e1adbc084 to your computer and use it in GitHub Desktop.
Save toandv/beb3febd6e5e1adbc084 to your computer and use it in GitHub Desktop.
private static final ObjectMapper objectMapper = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false).setSerializationInclusion(Include.NON_NULL)
.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
static {
objectMapper.getSerializerProvider().setNullKeySerializer(new NullKeySeriliazer());
objectMapper.setVisibility(objectMapper.getSerializationConfig().getDefaultVisibilityChecker()
.withFieldVisibility(JsonAutoDetect.Visibility.ANY).withGetterVisibility(JsonAutoDetect.Visibility.NONE)
.withSetterVisibility(JsonAutoDetect.Visibility.NONE)
.withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment