无法解析方法 spliterator JSONArray java8 流

我正在尝试在 JSONArray 上使用流(从 org.json.JSONArray 导入)(下面是另一个 stackoverflow 线程:How to iterate over a jsonarray in java8。但是,我的 IDE (intellij) 抱怨它无法解析方法 spliterator。我缺少什么?我在网上找不到任何解决方案。下面是代码:

private static Stream<Object> arrayToStream(JSONArray array) {
    return StreamSupport.stream(array.spliterator(), false);
}

在下面的屏幕截图中,您可以看到 IDE 向我显示的错误:

https://img.mukewang.com/6513f5ca0001261406160070.jpg

阿波罗的战车
浏览 47回答 1
1回答

绝地无双

您导入了正确的依赖项吗?这是来自 Maven 存储库的依赖项,它工作得很好!&nbsp;<!-- https://mvnrepository.com/artifact/org.json/json -->&nbsp; &nbsp; &nbsp; &nbsp;<dependency>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<groupId>org.json</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<artifactId>json</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<version>20190722</version>&nbsp; &nbsp; &nbsp; &nbsp;</dependency>与梯度:compile group: 'org.json', name: 'json', version: '20190722'或者您可以从这里下载:https://repo1.maven.org/maven2/org/json/json/20190722/json-20190722.jar
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java