[BUG]实体对象字段类型和json数据类型不一样,解析会报错
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*简要描述您碰到的问题。*
class A {
Integer id;
String content;
}
JSON字符串:
{"id":3568688690746472400,"content":"test"}
A result = JSONObject.parseObject(str, A.class);
解析报错:
Exception in thread "main" com.alibaba.fastjson2.JSONException: integer overflow 3568688690746472400
### 环境信息
- 版本信息:fastjson2-2.0.40.jar
### 期待的正确结果
希望不抛出异常,而是正常返回对象,对有问题的字段忽略。 不能因为个别问题字段影响整个对象的解析
Contributor guide
Research direction
Start by reproducing the issue through JSONObject.parseObject(str, A.class) with the JSON and Integer field shown in the report. Trace the deserialization path for the overflowing value and verify that parsing returns an object, preserves valid fields such as content, and does not throw for the problematic field.
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