Jackson Not Overriding Getter with @JsonProperty

前端 未结 10 2091
醉话见心
醉话见心 2021-02-12 06:23

JsonProperty isn\'t overriding the default name jackson gets from the getter. If I serialize the class below with ObjectMapper and jackson I get

<
10条回答
  •  你的背包
    2021-02-12 06:49

    Place it on the variable, not the getter

    class JacksonTester {
        @JsonProperty("hello")
        private String hi;
    
        public String getHi() {
            return hi;
        }
    } 
    

提交回复
热议问题