I have a Jackson configuration related question in my Spring boot project
As described in the spring boot blog
I am trying to set up serialization of objects.
After adding a new bean configuration in my configuration
@Bean public Jackson2ObjectMapperBuilder jacksonBuilder() { Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder(); builder.propertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); return builder; }
When I try to infer an instance of my User class, the json result is not in CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES
Class User { private String firstName = "Joe Blow"; public String getFirstName() { return firstName; } }
Json output:
{ "firstName": "Joe Blow" }
but not
{ "first_name": "Joe Blow" }
Maybe I need to register something in my jersey configuration in order to activate my own obejctMapper configuration
@Configuration public class JerseyConfig extends ResourceConfig { public JerseyConfig() { packages("my.package); } }
thanks
source share