Jackson Deserialization: unrecognized field

后端 未结 3 1292
说谎
说谎 2021-01-25 02:36

From the tutorial I had the impression that this should work (simplified example):

public class Foo {
    private String bar;
    public String getBar() {
              


        
3条回答
  •  一生所求
    2021-01-25 03:17

    You can configure ObjectMapper to ignore fields it doesn't find in your class with

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    

    If not configured this way, it will throw exceptions while parsing if it finds a field it does not recognize on the class type you specified.

提交回复
热议问题