alibaba / alibaba/fastjson2

[BUG]fastjson由1.83升级至2.0.52版本,instance of不生效

Open
#3,353 1 comment 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

```
public void findAll(JSONObject jsonObject, String findKey, Set includeSourceSet) {
for (String key : jsonObject.keySet()) {
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
findAll((JSONObject) value, findKey, includeSourceSet);
} else if (value instanceof JSONArray) {
JSONArray jsonArray = (JSONArray) value;
for (int i = 0; i < jsonArray.size(); i++) {
findAll(jsonArray.getJSONObject(i), findKey, includeSourceSet);
}
} else if (key.equals(findKey)) {
includeSourceSet.add(value.toString());
}
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported behavior from the code snippet with fastjson2 2.0.52 and compare it with version 1.83. Trace the runtime types returned by jsonObject.get(key), especially JSONObject and JSONArray values, then add a focused regression test. Done means the intended instanceof branches work consistently and the test passes.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.