Spring 如何忽略Jackson添加的默认属性?
我使用jackson制作JSON对象。我发现jackson会自动添加默认属性。我真的不需要这个字段,我如何删除它 这是我简化的代码Spring 如何忽略Jackson添加的默认属性?,spring,jackson,rabbitmq,Spring,Jackson,Rabbitmq,我使用jackson制作JSON对象。我发现jackson会自动添加默认属性。我真的不需要这个字段,我如何删除它 这是我简化的代码 @JsonIgnoreProperties(value = {"@id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, scope = CustomMessage.class) public class SystemMessage {
@JsonIgnoreProperties(value = {"@id"})
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, scope = CustomMessage.class)
public class SystemMessage {
private String body;
}
}
即使我添加了JsonIgnoreProperties注释,它也不会被删除。我想是因为“@id”是默认属性
{@id:1,“body”:“hello”}
这是我从rabbitMQ获得的消息。添加了
@Id
,因为@JsonIdentityInfo
注释-请参见您可以看到的地方,这是属性
字段的默认值
此注释用于父子关系,尤其是当对象之间存在循环依赖关系时。因此,如果这对您来说不是真的,您可以忽略此注释