【发布时间】:2014-03-22 03:18:00
【问题描述】:
在 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;
}
我不明白为什么它是必要的。能解释一下吗?
【问题讨论】:
标签: java json serialization jackson