powered by ASAP

PAKs default JSON handling is implemented in de.asap.pak.extra.impl.datatransformer.ObjectMapperFacade. In order to let PAK use this implementation, simply declare a dependency on de.asap.pak.extra:pak-default-datatransformer.

As the name suggests, we’re using Jackson as our backend JSON parser. The object mapper is configured to not fail on self references, write null on self references or fail on unknown properties.

In order to provide a better readable date format, we implemented a custom PAKTimeModule which is also registered to the object mapper. When a JSON string is encountered, which conforms to any of the supported formats, it is deserialized into an ExtensiveDateInfo object. This class combines all information that exists among date classes in java. The same applies for serialization, so most java time objects will be serialized into a JSON representation of the ExtensiveDateInfo class.

String format; // Human readable format of this representation

// Inferred from java date objects
Month month;
int monthValue;
int dayOfMonth;
DayOfWeek dayOfWeek;
int dayOfYear;
int year;

// Inferred from java time objects
int second;
int minute;
int hour;

// Inferred from java zoned objects
ZoneId zoneId;
ZoneOffset zoneOffset;

// Inferred from instants
long epochSecond;
int nano;

Supported date formats are ISO Instant, RFC 1123, ISO OffsetDateTime, ISO ZonedDateTime, ISO DateTime, „yyyy-MM-dd“.