Skip to content

Instantly share code, notes, and snippets.

@jhoelter
Created September 27, 2016 20:03
Show Gist options
  • Select an option

  • Save jhoelter/4b074e91fcc683fb922d5ad66b34bb11 to your computer and use it in GitHub Desktop.

Select an option

Save jhoelter/4b074e91fcc683fb922d5ad66b34bb11 to your computer and use it in GitHub Desktop.
JacksonConfig for HATEOAS
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
/**
* Created by jeremie.hoelter on 27.09.2016.
*/
@Configuration
public class JacksonConfiguration {
@Bean
@Primary
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
return objectMapper;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment