发送JSON请求时出现问题
当我以JSON格式发送REST请求时,我遇到了一个问题。当它调用服务时,一些参数丢失。但是,当我以xml格式发送请求时,它工作正常。我遇到的问题抛出以下错误:发送JSON请求时出现问题,json,rest,jersey,jackson,jax-rs,Json,Rest,Jersey,Jackson,Jax Rs,当我以JSON格式发送REST请求时,我遇到了一个问题。当它调用服务时,一些参数丢失。但是,当我以xml格式发送请求时,它工作正常。我遇到的问题抛出以下错误: SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container com.fasterxml.jackson.databind.exc.
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"
对象映射器类如下所示:
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);
有人能帮我解决这个问题吗
谢谢。您只有用于序列化的
WRAP\u ROOT\u值。记住,序列化是从POJO到JSON的转换。SerializationFeature.WRAP_ROOT_值
是在创建JSON时实际添加的“create_session_param”
我们需要JSON到POJO,这是反序列化,它有自己的特性集。在这种情况下,我们需要一个特性来un在JSON中包装根值。这是有原因的
我也是
你能给出你正试图序列化的类(无论如何,相关部分)和你正试图解析的JSON的一个例子吗?@AlexTaylor我已经更新了Q。你能帮忙吗。
mapper.configure(DeserializationFeature UNWRAP_ROOT_VALUE, true);