3

I'm reading about the Java API for Json Processing, specified in ths site. However, when I try to test such code like:

JsonReader reader = Json.createReader(new FileInputStream(...));

I can't, cause neither JsonReader class or Json class can't be imported from nowhere. I only get some JsonParser class which is imported from sun.org.mozilla.javascript.internal.json.JsonParser but obviously it isn't what I'm trying to get.

I have Java EE installed and I'm working with the Java EE version of Netbeans. How can I seize these features?

diegoaguilar
  • 8,179
  • 14
  • 80
  • 129

3 Answers3

2

Here is the download page for the reference implementation jar of JSR-000353

https://java.net/projects/jsonp/downloads/directory/ri

If you are using JSON I recommend the Jackson JSON library.

http://wiki.fasterxml.com/JacksonHome

The jar files can be found here:

http://wiki.fasterxml.com/JacksonDownload

For further information on the difference in implementations please see this question Differentiating the Jersey, Jackson, and JaxB APIs

Community
  • 1
  • 1
Nathaniel Johnson
  • 4,731
  • 1
  • 42
  • 69
  • Well, as it's part of the Java EE version, shouldn't it be at reach from the core libraries? – diegoaguilar Sep 23 '13 at 01:58
  • 1
    Yes, if you have the full EE libraries installed. The library will be there but if you don't want to include the full JAX-RS libraries, just use this set of jars. I can look up which jar it is in if you want. – Nathaniel Johnson Sep 23 '13 at 02:00
  • Yes, please, where can I find it. And, These libraries will be at reach ONLY under a EE like project? Not under a simple Java Application? – diegoaguilar Sep 23 '13 at 02:12
  • See edit above. I gave the url for the reference of this actual library and for the Jackson JSON library. – Nathaniel Johnson Sep 23 '13 at 02:14
  • 1
    A god resource for tracking down where you can find a jar file is: http://www.findjar.com/index.x Just type in the class you are looking for and a list of possible jars will come up. – Nathaniel Johnson Sep 23 '13 at 02:21
  • How can I "add" this feature to a Java SE project once I downloaded the library? – diegoaguilar Sep 23 '13 at 02:22
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/37846/discussion-between-diego-and-emmentaler) – diegoaguilar Sep 23 '13 at 02:25
  • 3
    It's weird though, that such an important API is not included in Java SE (although, various XML processing API are included in core libraries). – jFrenetic May 05 '14 at 14:30
1

JSR 353 was released along with the Java EE 7 platform. JsonObject and JsonReader API can be used in two different ways:

  • Use a Java EE 7 compliant application server, such as GlassFish 4. In this case, the API is built in to the runtime and will be resolved correctly for you. You can use NetBeans, Eclipse or IntelliJ and if the server runtime is configured properly then it just works.

  • Alternatively, you can download the Reference Implementation from http://jcp.org/aboutJava/communityprocess/final/jsr353/index.html and integrate wit your application or container of your choice.

A good set of samples for using this API are available at https://github.com/arun-gupta/javaee7-samples/tree/master/json.

Arun Gupta
  • 3,965
  • 5
  • 31
  • 39
-1

To use JSON Processing in a Maven project you can use the following Maven coordinates:

    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.json</artifactId>
        <version>1.1</version>
        <scope>provided</scope>
    </dependency>

Or to include all of Java EE 8 add the following coordinates:

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>1.8</version>
        <scope>provided</scope>
    </dependency>

JSON Processing 1.1 includes new JSON Pointer, JSON Patch and JSON Merge.

Alex Theedom
  • 1,604
  • 15
  • 16