Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- public class JacksonConfiguration {
- private static final String SPRING_HATEOAS_OBJECT_MAPPER = "_halObjectMapper";
- @Autowired
- @Qualifier(SPRING_HATEOAS_OBJECT_MAPPER)
- private ObjectMapper springHateoasObjectMapper;
- @Primary
- @Bean(name = "objectMapper")
- ObjectMapper objectMapper() {
- JavaTimeModule javaTimeModule = new JavaTimeModule();
- javaTimeModule.addSerializer(ZonedDateTime.class, new ZonedDateTimeSerializer(DateTimeFormatter.ISO_INSTANT));
- springHateoasObjectMapper.registerModules(javaTimeModule);
- springHateoasObjectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- springHateoasObjectMapper.disable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS);
- springHateoasObjectMapper.disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS);
- springHateoasObjectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
- springHateoasObjectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
- springHateoasObjectMapper.enable(SerializationFeature.INDENT_OUTPUT);
- springHateoasObjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- return springHateoasObjectMapper;
- }
- }
Add Comment
Please, Sign In to add comment