Ram*_*y P 16 java json java-17
我们如何为 java 17 记录类创建添加字段级注释?
record Rectangle(double length, double width) { }
Run Code Online (Sandbox Code Playgroud)
Ram*_*y P 24
是的,我们可以使用字段级注释(@Target(ElementType.FIELD)定义中的注释)。
@JsonInclude(Include.NON_NULL)
record Rectangle(
@JsonProperty("lengthAlias") double length,
double width) { }
Run Code Online (Sandbox Code Playgroud)