Skip to content

Add support for setting PropertyNamingStrategy in Jackson2ObjectMapperFactoryBean [SPR-11431] #16057

@spring-projects-issues

Description

@spring-projects-issues

Marcel Overdijk opened SPR-11431 and commented

The current org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean has no direct support for setting the PropertyNamingStrategy.
This would be very useful to e.g. change output to snake_case instead of CamelCase.

Currently I use a MethodInvokingFactoryBean to do this like:

<bean id="objectMapper" class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean">
    <property name="dateFormat"><bean class="com.fasterxml.jackson.databind.util.ISO8601DateFormat" /></property>
    <property name="indentOutput" value="true" />
</bean>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject" ref="objectMapper" />
    <property name="targetMethod" value="setPropertyNamingStrategy" />
    <property name="arguments">
        <list>
            <bean class="com.fasterxml.jackson.databind.PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy" />
        </list>
    </property>
</bean>

Please add setPropertyNamingStrategy method to Jackson2ObjectMapperFactoryBean.


Affects: 4.0.1

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions