In Jackson, when you annotate a constructor with @JsonCreator
, you must annotate its arguments with @JsonProperty
. So this constructor
public Point(double x, double y) {
this.x = x;
this.y = y;
}
becomes this:
@JsonCreator
public Point(@JsonProperty("x") double x, @JsonProperty("y") double y) {
this.x = x;
this.y = y;
}
I don't understand why it's necessary. Can you please explain?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…