Skip to content

[BUG] JSONPath.eval not getting data #2542

@Cooperzzy

Description

@Cooperzzy

问题描述

Based on #1965, Fastjson JSONPath.eval 为null,与fastjson2不一致

环境信息

  • OS信息: [MacOS 12.7.4 M1 Pro 16 GB]
  • JDK信息: [Openjdk 17.0.6]
  • 版本信息:[Fastjson 2.0.49]

重现步骤

import com.alibaba.fastjson2.JSONPath;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class Issue1965_222 {
  
    @Test
    public void test() {
        String temp = "{\n" +
                "  \"code\": \"1003\", \n" +
                "  \"data\": [1, 2], \n" +
                "}\n";
        assertEquals(JSONPath.eval(temp, "$.data"), com.alibaba.fastjson.JSONPath.eval(temp, "$.data"));
    }
}

期待的正确结果

Expected :[1,2]
Actual :null

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions