Jackson ObjectMapper反序列化setVisibility的某些属性为None

时间:2015-02-03 21:50:35

标签: java json spring jackson deserialization

我使用外部团队提供的模型将JSON反序列化为Java对象。但是,JSON消息有一些字段无法转换,因为它不兼容: 示例:下面是抛出: org.codehaus.jackson.map.JsonMappingException: Can not construct instance of javax.xml.datatype.XMLGregorianCalendar from String value '17:00:00'

示例JSON消息:

"BirthDate": {
    "@type": "BirthDate",
    "startDate": "2015-01-19",
    "startTime": "17:00:00"}

我正在使用全局CustomObjectWrapper     公共类CustomObjectMapper扩展了ObjectMapper {

public CustomObjectMapper() {
    super();
    configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    AnnotationIntrospector pair = new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(), new JacksonAnnotationIntrospector());
    setAnnotationIntrospector(pair);
}

的pom.xml

<dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-jaxrs</artifactId>
        <version>1.9.4</version>
</dependency>

appContext.xml(弹簧)

<bean id="jsonObjectMapper" class="com.org.CustomObjectMapper"/>
<bean id="birthDataFormat" class="org.apache.camel.component.jackson.JacksonDataFormat">
  <constructor-arg ref="jsonObjectMapper"/>
  <constructor-arg value="com.external.org.PersonModel"/>
</bean> 

如何告诉杰克逊不转换startDatestartTime? 该模型不是我控制的东西,我无法再次编写所有模型。什么是候补?

0 个答案:

没有答案
相关问题