Issue
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 :
        success : function(response) {  
            if(response.State.isSet){   
                alert('success called successfully)
            }
Is the annotation @JsonProperty required here ? 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 ?
Solution
Here's a good example. I use it to rename the variable because the JSON is coming from a .Net environment where properties start with an upper-case letter.
public class Parameter {
  @JsonProperty("Name")
  public String name;
  @JsonProperty("Value")
  public String value; 
}
This correctly parses to/from the JSON:
"Parameter":{
  "Name":"Parameter-Name",
  "Value":"Parameter-Value"
}
                        
                        Answered By - OldCurmudgeon Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.