org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field

阅读更多

使用Jackson 反序列化时,报错:

org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "age" (Class com.common.bean.RequestInfoBean), not marked as ignorable
 at [Source: java.io.StringReader@32deb93a; line: 1, column: 151] (through reference chain: com.common.bean.RequestInfoBean["age"])

 

原因:

把json字符串jsonStr ,反序列化为RequestBean,当jsonStr 中的字段,java bean中没有时报错

解决方法:

mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);

 
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field_第1张图片
 

 

pom.xml:


            org.codehaus.jackson
            jackson-mapper-lgpl
            1.9.13
        

 参考:

http://blog.csdn.net/a9529lty/article/details/8232948

 

  • org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field_第2张图片
  • 大小: 60.9 KB
  • 查看图片附件

你可能感兴趣的:(jackson,反序列化)