Cannot resolve method spliterator JSONArray java8 streams

coffeeak :

I am trying to use streams on a JSONArray (imported from org.json.JSONArray) (following another stackoverflow thread here: How to iterate over a jsonarray in java8. However, my IDE (intellij) complains that it cannot resolve the method spliterator. What am I missing? I can't find any solution online. Below is the code:

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

Below in the screenshot, you can see the error the IDE is showing me: enter image description here

jordi :

Have you imported the correct dependencies?

Here you are the dependency from Maven repository which work fine!

 <!-- https://mvnrepository.com/artifact/org.json/json -->
       <dependency>
           <groupId>org.json</groupId>
           <artifactId>json</artifactId>
           <version>20190722</version>
       </dependency>

With gradle:

compile group: 'org.json', name: 'json', version: '20190722'

Or you can download it from here:
https://repo1.maven.org/maven2/org/json/json/20190722/json-20190722.jar

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=307737&siteId=1