当我将 Json-path 升级到 2.8 时,JSONParser 无法解析为类型

问题描述 投票:0回答:0

我有一个项目,正在使用jayway jsonpath

        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <version>2.7.0</version>
            <scope>compile</scope>
        </dependency>   

效果很好。

我尝试将其更新到最新版本2.8。

然后我遇到了一些奇怪的编译错误:

JSONParser cannot be resolved to a type
JSONObject cannot be resolved to a type
在一个 Java 文件中。虽然在测试范围内的另一个 Java 文件中完全相同的代码没有问题。

我在命令行中尝试了它并遇到了同样的问题。所以,这不是IDE问题。 我又检查了maven依赖中的版本冲突,没有发现冲突。 这是相关代码:

import net.minidev.json.JSONObject;
import net.minidev.json.parser.JSONParser;
import net.minidev.json.parser.ParseException;


    public static JSONObject convertJSONStr2Obj(String jsonStr) throws FileNotFoundException, URISyntaxException, ParseException {
        JSONObject expectedJson = (JSONObject)new JSONParser(JSONParser.DEFAULT_PERMISSIVE_MODE).parse(jsonStr);
        return expectedJson;
    }
java jsonpath
© www.soinside.com 2019 - 2024. All rights reserved.