json序列化问题

object to json 用的是get方法,getName{ return "text"} 返回的是"name": "test", 可以用jsonIgnore来忽略json,那么将不会出现这个属性。

@JsonIgnore
    public String getText() {
        return text;
    }

·································

json to object 用的是set方法

如果json 中有name 属性,但是类中没有找到setName,那么将需要@JsonProperty("name")来帮助找到。

@JsonProperty("name")
    public void setText(String text) {
        this.text = text;
    }

猜你喜欢

转载自blog.csdn.net/qq_27988103/article/details/83510473