blocks.service.JsonUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of service-block Show documentation
Show all versions of service-block Show documentation
Blocks Framework - service-block
package blocks.service;
import akka.http.javadsl.marshallers.jackson.Jackson;
import akka.http.javadsl.marshalling.Marshaller;
import akka.http.javadsl.model.HttpEntity;
import akka.http.javadsl.model.RequestEntity;
import akka.http.javadsl.unmarshalling.Unmarshaller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
public class JsonUtil {
public static final ObjectMapper DEFAULT_OBJECT_MAPPER = getObjectMapper();
private static ObjectMapper getObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new Jdk8Module());
objectMapper.registerModule(new JavaTimeModule());
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
return objectMapper;
}
public static Marshaller marshaller() {
return Jackson.marshaller(DEFAULT_OBJECT_MAPPER);
}
public static Unmarshaller unmarshaller(Class classParam) {
return Jackson.unmarshaller(DEFAULT_OBJECT_MAPPER, classParam);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy