[BUG] Parse similar attributes with underline
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
[https://github.com/alibaba/fastjson/issues/1089](url) ,fastjson兼容依旧存在此问题。
### 环境信息
- OS信息: [MacOS 12.7.4 M1 Pro 16 GB]
- JDK信息: [Openjdk 17.0.6]
- 版本信息:[Fastjson 2.0.51]
### 重现步骤
```java
import com.alibaba.fastjson.JSON;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Created by wenshao on 20/03/2017.
*/
public class Issue1089 {
@Test
public void test_for_issue() throws Exception {
String json = "{\"ab\":123,\"a_b\":456}";
TestBean tb = JSON.parseObject(json, TestBean.class);
assertEquals(123, tb.getAb());
}
public static class TestBean {
private int ab;
public int getAb() {
return ab;
}
public void setAb(int ab) {
this.ab = ab;
}
}
}
```
### 相关日志输出
Expected :123
Actual :456
Contributor guide
Research direction
Start from the JSON.parseObject call in the Issue1089 reproduction and inspect the deserialization path for TestBean when both "ab" and "a_b" are present. Add or adapt a regression test using the shown JSON and verify that the bean keeps ab=123 rather than assigning 456.
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
- Clearly specified
- Newbie friendliness
- 55/100