Skip to content

Spring Boot Jackson properties are ignored #15

Closed
@jmirandac

Description

@jmirandac

Hi,

Really nice library, but regarding Spring integration and Dates' formatting, I'm suffering some lacks of customization.

When integrating with Spring Boot, Jackson configuration is ignored. This is what I've in my application.properties which works when not using the JsonView library:

# Jackson serialization config
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false
spring.jackson.date-format = dd-MM-yyyy HH:mm:ss

So, my question is... there any way to use the ObjectMapper configured and instantiated by Spring when parsing the objects? Even I've tried to instantiate a custom ObjectMapper and pass it to the @bean when configuring the JsonViewSupportFactoryBean, instead of using the default mapper, something like:

@Bean
public JsonViewSupportFactoryBean views() { 
      ObjectMapper mapper = new ObjectMapper();
      mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
      mapper.setDateFormat(new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"));
      return new JsonViewSupportFactoryBean(mapper);
}

But it didn't work. Dates are shown as numbers like timestamps.

I think there are customizations like date formatting which have been ignored, and it would be really nice if they could be taken into account here. Is it possible?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions