[BUG]JSONPath.contains和JSONPath.eval输出结果不一致

Open Beginner friendly
#7,771 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java
Domain
backend

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

bug
问题描述

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from alibaba/fastjson2

All issues in alibaba/fastjson2

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.