alibaba / alibaba/fastjson2

[FEATURE]在解析"非完全正确的JSON文本"时,可否先尽可能的尝试解析操作?

Open
#2,105 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 请描述您的需求或者改进建议
*对您想要需求或建议的清晰简洁的描述。*
假设有以下Json Text:
```json
{
"uid": "123456789",
"clientSn": "A0001",
"model": {
"identity": "client",
"dataformat": "HEX",
"uid": "10086",
"protocol": "TCP",
"type":"CMD",
}
}
```
> 注意: `type` 属性值后的逗号`,`并为去除!

我尝试了27种的 `JSONReader.Feature.*`后,依旧为报错!

##### 期待
可否对 多余的逗号自动进行去除(或修正. 举例说明,并非仅限于此处情况!) 亦或 给予`友好的错误提示`方式(相比较更倾向于前面选择)!

### 请描述你建议的实现方案
*对您想要需求或建议的实现方案的详细描述。*

### 描述您考虑过的替代方案
*对您考虑过的任何替代解决方案或功能的描述。*

#### 附加信息
*如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。*
Version: fastjson2-2.0.43
Springboot: 3.2.0
JDK: OpenJDK 21.0.1

Contributor guide

Open the contributing guide

Research direction

Start with JSONReader.Feature and reproduce the supplied JSON containing a trailing comma using fastjson2 2.0.43. Determine whether the requested behavior should accept this malformed input or provide a friendlier error, and define completion with a regression test for the chosen behavior and related malformed JSON cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.