alibaba / alibaba/fastjson2

[BUG]JSONValidator#validate进行json校验时,未正确识别

Open
#4,032 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 问题描述
一个非常简单的,带有反斜杠的json,识别失败了(明明是json,但是识别结果却为false)

### 环境信息
*请填写以下信息:*

- OS信息: windows 10
- JDK信息: Openjdk 17
- 版本信息:Fastjson2最新版:2.0.61

### 重现步骤
*如何操作可以重现该问题:*
运行下述main方法即可重现
```java
public static void main(String[] args) {
// 对字符串: {"dir": "C:\Users"}
JSONValidator jsonValidator = JSONValidator.from("{\"dir\": \"C:\\Users\"}");

// 期望输出为 true,但是 实际上输出了 false
System.err.println(
jsonValidator.validate()
);
}
```

### 期待的正确结果
上述代码期望输 true

### 相关日志输出

#### 附加信息

Image

Contributor guide

Open the contributing guide

Research direction

Start at JSONValidator#validate and reproduce the issue with the supplied main method using the escaped Windows path. Trace how the validator handles the backslash in the JSON string, then verify that validate() returns true for this input and add or run a regression check if the project’s existing tests cover this entry point.

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
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.