我们如何为 java 17 条记录 class 提供 Jackson 注释

How can we provide Jackson annotations for java 17 record class

我们如何为 java 17 条记录 class 添加字段级注释?

record Rectangle(double length, double width) { }

是的,我们可以使用字段级注释(定义中带有 @Target(ElementType.FIELD) 的注释。

@JsonInclude(Include.NON_NULL)
record Rectangle(
    @JsonProperty("lengthAlias") double length,
    double width) { }