When is the @JsonProperty property used and what is it used for?
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"
}
I think OldCurmudgeon and StaxMan are both correct but here is one sentence answer with simple example for you.
@JsonProperty(name), tells Jackson ObjectMapper to map the JSON property name to the annotated Java field's name.
//example of json that is submitted
"Car":{
"Type":"Ferrari",
}
//where it gets mapped
public static class Car {
@JsonProperty("Type")
public String type;
}