Does Java 9 contain built-in JSON?

怎甘沉沦 提交于 2021-02-08 09:43:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!