Problem Description
Methods annotated with @com.fasterxml.jackson.annotation.JsonProperty are ignored on record types.
It worked as expected up to version 2.58.
It works as expected on class types.
Environment
- OS: macOS 26.1
- JDK: openjdk 21.0.2
- fastjson2: 2.60
How to reproduce the problem
Add following libraries to classpath:
com.fasterxml.jackson.core:jackson-annotations:2.20
com.alibaba.fastjson2:fastjson2:2.0.60
Minimal reproducer:
import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.annotation.JsonProperty;
record Foo(int x) {
@JsonProperty
public int y() {
return 42;
}
public static void main(String[] args) {
Foo foo = new Foo(5);
Object json = JSON.toJSON(foo);
System.out.println(json);
}
}
Expected output
{"x":5,"y":42}
Actual output
{"x":5}
Problem Description
Methods annotated with
@com.fasterxml.jackson.annotation.JsonPropertyare ignored onrecordtypes.It worked as expected up to version 2.58.
It works as expected on
classtypes.Environment
How to reproduce the problem
Add following libraries to classpath:
Minimal reproducer:
Expected output
{"x":5,"y":42}Actual output
{"x":5}