问题
I was wondering if Java 9 has built-in support for JSON. If so how can I import it? I'm writing a socket program so I'm not talking about Java EE and my target to import to is a simple Java SE class.
回答1:
There was a proposal to drop the feature by Mark Reinhold, Oracle’s Head of the Java:
We may reconsider this [JSON API] JEP for JDK 10 or a later release, especially if new language features such as value types and generics over primitive types (JEP 218) enable a more compact and expressive API.
And it doesn't appear in the finalized features. So it appears Java 9 doesn't have a native JSON API.
回答2:
There is JSON-P which has a JSR.
JSON Processing (JSON-P) is a Java API to process (for e.g. parse, generate, transform and query) JSON messages. It produces and consumes JSON text in a streaming fashion (similar to StAX API for XML) and allows to build a Java object model for JSON text using API classes (similar to DOM API for XML).
That's as close as you can get to official JSON support in Java.
来源:https://stackoverflow.com/questions/50050260/does-java-9-contain-built-in-json