Spring's XML based bean configuration for Object Mapper's Case Insensitive property

18 views Asked by At

I am trying to accept case insensitive fields to my API running on JBoss Server.

Currently I have a Spring Boot Project. But i have a sprintApplicationContext.xml that i have contextConfigured inside web.xml.

When i try below code for MapperFeature's Case Insensitive property, it is not working.

    @Bean
    public ObjectMapper objectMapper() {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
        return mapper;
    }

Then i tried the Same Bean configuration with Jackson Object Mapper like below(With the help of ChatGPT)

    <bean id="objectMapper" class="com.fasterxml.jackson.databind.ObjectMapper">
        <property name="configOverrides">
            <bean class="com.fasterxml.jackson.databind.cfg.MapperConfigOverrides">
                <!-- Add custom configuration options here -->
                <!-- For example, enable a feature -->
                <property name="mapperFeatures">
                    <bean class="com.fasterxml.jackson.databind.cfg.MapperConfig$EnumResolverBuilder" factory-method="construct">
                        <constructor-arg type="com.fasterxml.jackson.databind.MapperFeature"/>
                        <constructor-arg>
                            <set>
                                <value>ACCEPT_CASE_INSENSITIVE_PROPERTIES</value>
                            </set>
                        </constructor-arg>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>

0

There are 0 answers