Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we provide Jackson annotations for java 17 record class

How can we create add field level annotations for java 17 record class?

record Rectangle(double length, double width) { }
like image 399
RamiReddy P Avatar asked Sep 12 '25 11:09

RamiReddy P


1 Answers

yes we can use field level annotations (annotation with @Target(ElementType.FIELD) in the defination.

@JsonInclude(Include.NON_NULL)
record Rectangle(
    @JsonProperty("lengthAlias") double length,
    double width) { }
like image 176
RamiReddy P Avatar answered Sep 15 '25 00:09

RamiReddy P



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!