在Jackson中,当你用一个构造函数注释时@JsonCreator,你必须用它来注释它的参数@JsonProperty.所以这个构造函数
public Point(double x, double y) {
this.x = x;
this.y = y;
}
Run Code Online (Sandbox Code Playgroud)
成为这个:
@JsonCreator
public Point(@JsonProperty("x") double x, @JsonProperty("y") double y) {
this.x = x;
this.y = y;
}
Run Code Online (Sandbox Code Playgroud)
我不明白为什么这是必要的.你能解释一下吗?