何时使用 @JsonProperty 属性,它的用途是什么? - When is the @JsonProperty property used and what is it used for?

10/14 06:01
阅读数 0

问题:

This bean 'State' :这个豆“状态”:

public class State {

    private boolean isSet;

    @JsonProperty("isSet")
    public boolean isSet() {
        return isSet;
    }

    @JsonProperty("isSet")
    public void setSet(boolean isSet) {
        this.isSet = isSet;
    }

}

is sent over the wire using the ajax ' success' callback :使用 ajax 'success' 回调通过网络发送:

        success : function(response) {  
            if(response.State.isSet){   
                alert('success called successfully)
            }

Is the annotation @JsonProperty required here ?这里需要@JsonProperty 注释吗? What is the advantage of using it ?使用它有什么好处? I think I can remove this annotation without causing any side effects.我想我可以在不引起任何副作用的情况下删除此注释。

Reading about this annotion on https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations I don't know when this is required to be used ?https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations上阅读此注释我不知道什么时候需要使用它?


解决方案:

参考一: https://en.stackoom.com/question/qnZu
参考二: https://stackoom.com/question/qnZu
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部