Reputation: 410
I am facing an issue when i am sending a REST request in JSON format.Some of the parameters are getting missed when it invokes the service.However it works fine when i send the request in xml format.The issue which i am geting throws below error:
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "create_session_param"
The object mapper class looks as below:
objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,true);
JaxbAnnotationModule module = new JaxbAnnotationModule();
// maintain JAXB annotation support
objectMapper.registerModule(module);
Can someone please help me to resolve this?
Thanks.
Upvotes: 1
Views: 168
Reputation: 208984
You only have WRAP_ROOT_VALUE
which is for serialization. Remember serialization is POJO to JSON. The SerializationFeature.WRAP_ROOT_VALUE
is the one that actually adds the "create_session_param"
when creating the JSON.
We need JSON to POJO, which is deserialization, which has its own feature set. In this case, we need a feature to unwrap the root value in the JSON. For that there is
So do
mapper.configure(DeserializationFeature UNWRAP_ROOT_VALUE, true);
Upvotes: 1