[BUG]:fastjson2 parseObject 会将String成功转成List 而不是失败
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 环境信息
- 版本信息:[e.g.:Fastjson2 2.0.53]
### 重现步骤
1. 使用 `JSONObject.parseObject` 方法
2. 输入 `"{\"xxx\": \"\"}"` 数据
```java
import com.alibaba.fastjson2.JSONObject;
import java.util.List;
public class Main {
public static void main(String[] args) {
var str = "{\"xxx\": \"\"}";
var fastjson = JSONObject.parseObject(str, TestObject.class);
System.out.println(fastjson);
System.out.println(fastjson.xxx());
}
}
record TestObject(List xxx) {
}
```
### 期待的正确结果
正常来说应该失败的,但是它居然成功了。
### 相关日志输出
TestObject[xxx=[]]
[]
#### 附加信息
[错误位置](https://github.com/alibaba/fastjson2/blob/2b0efeee501f9fc6ab215910a51491edfe43784e/core/src/main/java/com/alibaba/fastjson2/reader/ObjectReaderImplListStr.java#L198)
Contributor guide
Research direction
Run the supplied Java reproduction using JSONObject.parseObject with TestObject and a List field, then inspect core/src/main/java/com/alibaba/fastjson2/reader/ObjectReaderImplListStr.java around line 198. Confirm the current conversion of an empty String and define the regression check so that this input fails instead of producing an empty list.
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
- 45/100