杰克逊@JsonProperty注释递归工作?

时间:2014-09-26 15:31:23

标签: java annotations jackson

我想知道@JsonProperty注释是否递归工作?

例如:

public class AirTravelerType {

    @JsonProperty
    protected ProfileRef profileRef;

    @JsonProperty
    protected PersonNameType personName;

    @JsonProperty
    protected List<Telephone> telephone;

我找不到任何关于此的答案。有人可以为我澄清一下吗?我是否必须前往ProfileRef和其他人用注释标记其字段? 或者像我在代码片段中提到的那样,这就足够了吗?

2 个答案:

答案 0 :(得分:0)

JsonProperty as exaplained here用于指定json属性名称。要知道它是否以递归方式工作,您必须检查对象ProfileRef的结构。

答案 1 :(得分:0)

我调查了这个行为。

可以说它确实 递归

在主模型类中编写注释就足够了。