use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project ArTEMiS by ls1intum.
the class TestUtil method convertObjectToJsonBytes.
/**
* Convert an object to JSON byte array.
*
* @param object
* the object to convert
* @return the JSON byte array
* @throws IOException
*/
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JavaTimeModule module = new JavaTimeModule();
mapper.registerModule(module);
return mapper.writeValueAsBytes(object);
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project jhipster-sample-app-dto by jhipster.
the class TestUtil method convertObjectToJsonBytes.
/**
* Convert an object to JSON byte array.
*
* @param object
* the object to convert
* @return the JSON byte array
* @throws IOException
*/
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JavaTimeModule module = new JavaTimeModule();
mapper.registerModule(module);
return mapper.writeValueAsBytes(object);
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project SONG by overture-stack.
the class JsonUtils method mapper.
public static ObjectMapper mapper() {
val specialModule = new SimpleModule();
specialModule.addDeserializer(String.class, SpecialStringJsonDeserializer.instance);
val mapper = new ObjectMapper().registerModule(new ParameterNamesModule()).registerModule(new Jdk8Module()).registerModule(specialModule).registerModule(new JavaTimeModule());
mapper.disable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES);
mapper.disable(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.disable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE);
// Doesn't work! Fields with the value '""' (empty string) are not being deserialized as null.
// mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
mapper.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
return mapper;
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project api-core by ca-cwds.
the class LoggingFilter method filter.
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
LOG.info(System.getProperty(LINE_SEPARATOR) + "!!! Test Request" + System.getProperty(LINE_SEPARATOR) + "!!! URL: {}" + System.getProperty(LINE_SEPARATOR) + "!!! Method: {}" + System.getProperty(LINE_SEPARATOR) + "!!! Body: {}", requestContext.getUri(), requestContext.getMethod(), mapper.writerWithDefaultPrettyPrinter().writeValueAsString(requestContext.getEntity()));
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project jhipster-sample-app-oauth2 by jhipster.
the class TestUtil method convertObjectToJsonBytes.
/**
* Convert an object to JSON byte array.
*
* @param object
* the object to convert
* @return the JSON byte array
* @throws IOException
*/
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JavaTimeModule module = new JavaTimeModule();
mapper.registerModule(module);
return mapper.writeValueAsBytes(object);
}
Aggregations