[BUG]JSONPath.contains和JSONPath.eval输出结果不一致
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start by running the provided Java reproduction against Fastjson2 2.0.60, then inspect JSONPath.contains and JSONPath.eval for how they process $.status. Add a regression test covering the shown JSON and path, and confirm that both methods consistently report the existing value.
Written by the indexing model from the issue text.
Description
问题描述
JSONPath.contains结果为false,但JSONPath.eval可以取到值
环境信息
- OS信息: NA
- JDK信息:Openjdk 21.0.8
- 版本信息:Fastjson2 2.0.60
重现步骤
private void test1() {
String s = """
{"status": 200}
""";
boolean contains = JSONPath.contains(s, "$.status");
Object eval = JSONPath.eval(s, "$.status");
System.out.println(eval); // 返回 200
System.out.println(contains); // 返回 false 期望返回 true
}
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 611
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from alibaba/fastjson2
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
[BUG] `ArrayIndexOutOfBoundsException` on a field name ending in a backslash — `JSON.parse("{\"\\")` Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
All issues in alibaba/fastjson2
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100