use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project openremote by openremote.
the class ValueUtil method configureObjectMapper.
public static ObjectMapper configureObjectMapper(ObjectMapper objectMapper) {
objectMapper.setConstructorDetector(ConstructorDetector.DEFAULT).setSerializationInclusion(JsonInclude.Include.NON_NULL).configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, // see https://github.com/FasterXML/jackson-databind/issues/1547
false).configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false).enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS).configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE).setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY).setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY).registerModule(new Jdk8Module()).registerModule(new JavaTimeModule()).registerModule(new ParameterNamesModule(JsonCreator.Mode.DEFAULT));
objectMapper.configOverride(Map.class).setInclude(JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL));
SimpleFilterProvider filters = new SimpleFilterProvider();
filters.setFailOnUnknownId(false);
objectMapper.setFilterProvider(filters);
return objectMapper;
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project snow-owl by b2ihealthcare.
the class SnowOwlApiConfig method createObjectMapper.
public static ObjectMapper createObjectMapper() {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.setSerializationInclusion(Include.NON_NULL);
final StdDateFormat dateFormat = new StdDateFormat();
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
objectMapper.setDateFormat(dateFormat);
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
objectMapper.addMixIn(Metadata.class, MetadataMixin.class);
objectMapper.addMixIn(MetadataHolder.class, MetadataHolderMixin.class);
return objectMapper;
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project alf.io by alfio-event.
the class BaseConfiguration method objectMapper.
@Bean
ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
return mapper;
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project eap-additional-testsuite by jboss-set.
the class Jsr310DeserializationTestCase method testDurationDeserialization.
@Test
public void testDurationDeserialization() throws Exception {
ObjectReader reader = new ObjectMapper().registerModule(new JavaTimeModule()).readerFor(Duration.class);
final String INPUT = "1e10000000";
// this should return almost instantly
Duration value = reader.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS).readValue(INPUT);
Assert.assertEquals("Didn't get the expected value.", 0, value.getSeconds());
}
use of com.fasterxml.jackson.datatype.jsr310.JavaTimeModule in project Spring-5.0-By-Example by PacktPublishing.
the class RedisConfiguration method mapper.
@Bean
@Primary
public ObjectMapper mapper() {
final ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.registerModule(new JavaTimeModule());
return mapper;
}
Aggregations