在Jackson中,当你用@JsonCreator
注释构造函数时,你必须用@JsonProperty
注释它的参数。所以这个构造函数
public Point(double x, double y) {
this.x = x;
this.y = y;
}
变成这样:
@JsonCreator
public Point(@JsonProperty("x") double x, @JsonProperty("y") double y) {
this.x = x;
this.y = y;
}
我不明白为什么这是必要的。你能解释一下吗?
https://stackoverflow.com/questions/21920367
复制相似问题