简体   繁体   中英

JSONParser missing from JDK

I have JDK 11 installed on my machine. I had thought that a JSON parser is now included standard with the JDK. However when I try to resolve the javax.json.* package Eclipse tells me that it is now found. Why?

Tried searching for an answer and am coming up dry. Would appreciate an answer or a link to one.

Thank you

Yes they are available as a part of Java ME and EE and not in SE.

https://docs.oracle.com/javame/8.0/api/json/api/index.html?com/oracle/json/stream/JsonParser.html

https://docs.oracle.com/javaee/7/api/javax/json/stream/JsonParser.html

Try using Java ME or EE, you'll get that.

//Happy learning..!

Right, there is a difference between Java EE and Java SE. JSON parsing is needed with enterprise applications nowadays. Oracle has a dependency you can download:

https://javaee.github.io/jsonp/

If you are using maven, you can just include this in your POM:

<!-- https://mvnrepository.com/artifact/javax.json/javax.json-api -->
<dependency>
    <groupId>javax.json</groupId>
    <artifactId>javax.json-api</artifactId>
    <version>1.1.4</version>
</dependency>

BUT , this has been superseded by the Jakarta EE package (ee4j):

(GitHub download) https://github.com/eclipse-ee4j/jsonp

(Maven download)

<!-- https://mvnrepository.com/artifact/jakarta.json/jakarta.json-api -->
<dependency>
    <groupId>jakarta.json</groupId>
    <artifactId>jakarta.json-api</artifactId>
    <version>1.1.6</version>
</dependency>

If you look at EE4J, you can see there are so many APIs you can download. Java SE would be so bloated with them by default. For a while, Oracle was just distributing these 'reference implementations' of Java EE packages as well along with various servers like Glassfish. There are so many ways to handle these protocols and formats like JSON, and on the job these may be mission-critical.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM