Jackson Deserialization: unrecognized field

后端 未结 3 1318
说谎
说谎 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:03

    It will work if you pull your Qux class out of Foo

    public class Foo {
        private String bar;
    
        // added this
        private Qux qux;
    
        public String getBar() {
            return bar;
        }
        public void setBar(String bar) {
            this.bar = bar;
        }
    
        // added getter and setter
        public Qux getQux() {
            return qux;
        }
        public void setQux(Qux qux) {
            this.qux = bar;
        }
    }
    
    public static class Qux {
        private String foobar;
        public String getFoobar() {
            return foobar;
        }
        public void setFoobar(String foobar) {
            this.foobar = foobar;
        }
    }
    

提交回复
热议问题