[BUG]
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*简要描述您碰到的问题。*
在线上生产环境
@JSONField(name = "id")
注解没有按name设置
### 环境信息
*请填写以下信息:*
- OS信息: [e.g.:Linux MONITOR-MPP 2.6.32-431.el6.x86_64 #1 SMP Fri Mar 28 08:38:24 CST 2014 x86_64 x86_64 x86_64 GNU/Linux]
- JDK信息: [e.g.:oracle jdk 1.8.0_144]
- 版本信息:[e.g.:Fastjson2 2.0.17]
### 重现步骤
*如何操作可以重现该问题:*
类信息
class A{
@JSONField(name = "id")
private String id;
@JSONField(name = "info")
private FileInfo info;
}
class FileInfo{
private String id;
@JSONField(name = "id")
private String fileId;
}
json信息
{
"id": "aaaa",
"info": {
"id": "ffff"
}
}
1. 使用 `JSONObject.parseObject(json).to(A.class)` 方法
2. 输入 `{"id":"aaaa","info":{"id":"ffff"}}` 数据
3. 出现 `A = {
id = "aaaa",
FileInfo = {
id = "ffff"
fileId = null
}
}` 错误
### 期待的正确结果
*对您期望发生的结果进行清晰简洁的描述。*
A = {
id = "aaaa",
info = {
id = null
fileId = "ffff"
}
}
PS:按注解结果来说 fileId 值为 "ffff"(本地开发测试正常 fileId 值为 "ffff"),但可能线上系统版本过旧,fileId值为空,"ffff"设到了FileInfo 的id 上
Contributor guide
Research direction
Reproduce the issue with classes A and FileInfo, their @JSONField annotations, and JSONObject.parseObject(json).to(A.class). Compare the result with the expected mapping, where nested "id" populates fileId and FileInfo.id remains null; confirm whether the behavior depends on the Fastjson2 version used in production.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100