Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions powertools-serialization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.joda.JodaModule;

import io.burt.jmespath.JmesPath;
import io.burt.jmespath.RuntimeConfiguration;
Expand All @@ -41,11 +42,13 @@ public final class JsonConfig {
// Don't throw an exception when json has extra fields you are not serializing on.
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// Ignore null values when writing json.
.serializationInclusion(JsonInclude.Include.NON_NULL)
.defaultPropertyInclusion(
JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.USE_DEFAULTS))
// Write times as a String instead of a Long so its human-readable.
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
// Sort fields in alphabetical order
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
.addModule(new JodaModule())
.build();

private static final ThreadLocal<ObjectMapper> om = ThreadLocal.withInitial(objectMapperSupplier);
Expand Down
Loading
Loading