使用lombok,字段的第二个字母不是大写,转换后就可以达到期望的字段,反之,则达不到期望字段 @wenshao
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
版本:2.0.36
使用lombok,字段的第二个字母不是大写,转换后就可以达到期望的字段,反之,则达不到期望字段 @wenshao
```java
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter;
import lombok.Data;
import lombok.experimental.Accessors;
public class Demo {
public static void main(String[] args) {
var dto = new TestDTO().setUId(1).setUserId(123);
System.out.println(JSON.toJSONString(dto, JSONWriter.Feature.PrettyFormat));
}
@Accessors(chain = true)
@Data
static class TestDTO {
/**
* 第二个字母小写
*/
private Integer userId;
/**
* 第二个字母大写
*/
private Integer uId;
}
}
```
输出结果如图:
_Originally posted by @iv587 in https://github.com/alibaba/fastjson2/issues/810#issuecomment-1645380571_
Contributor guide
Research direction
Start with the Java reproduction in the issue and inspect how Lombok-generated accessors for userId and uId are discovered during JSON serialization. Verify the serialized output for both fields and consider the issue complete when their property names match the declared fields and expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100