Skip to content

Extension module for supporting reading and writing of JSR-353 tree node types using Jackson streaming API

Notifications You must be signed in to change notification settings

steinarb/jackson-datatype-jsr353

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

260 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Datatype module to make Jackson recognize JsonValue types of JSON API defined in JSR-353 ("JSON-Processing"), so that you can read JSON as JsonValues and write JsonValues as JSON as part of normal Jackson processing.

Note that there is also a related jackson-javax-json module which actually implements JSR-353 using Jackson streaming API under the hood.

In both cases the main reason for use is interoperability, as well as to take advantage of powerful data-binding features Jackson provides. Another benefit is the performance: Jackson implementation is often significantly faster for reading and writing JSON content than Oracle's JSR-353 Reference Implementation.

Status

Build Status Maven Central Javadoc

As of 2.3 module is considered stable and production ready.

Usage

Maven dependency

To use module on Maven-based projects, use following dependency:

<dependency>
  <groupId>com.fasterxml.jackson.datatype</groupId>
  <artifactId>jackson-datatype-jsr353</artifactId>
  <version>2.9.0</version>
</dependency>

(or whatever version is most up-to-date at the moment)

Also unless you already include a dependency to a JSR-353 implementation (JDK does not ship with one at least with JDK 8 and prior), you may need to include one. Implementations include:

Reference implementation (last updated in 2013) dependency would be:

<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.json</artifactId>
    <version>1.0.4</version>
</dependency>

Registering module

Like all standard Jackson modules (libraries that implement Module interface), registration is done as follows:

ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JSR353Module());

after which functionality is available for all normal Jackson operations: you can read JSON as JsonValue (or its subtypes), JsonValues as JSON, like:

JsonObject ob = mapper.readValue(JSON, JsonObject.class);
mapper.writeValue(new File("stuff.json"), ob);

More

See Wiki for more information (javadocs, downloads).

About

Extension module for supporting reading and writing of JSR-353 tree node types using Jackson streaming API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%