Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Feb 15, 2014 · 0 comments
Assignees
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Feb 15, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants