Apache Johnzon is a project providing an implementation of JsonProcessing (aka jsr-353) and a set of useful extension for this specification like an Object mapper and some JAX-RS providers.
Johnzon comes with three main modules.
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-core</artifactId>
<version>${johnzon.version}</version>
</dependency>
This is the implementation of the specification. You’ll surely want to add the API as dependency too:
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-json_1.0_spec</artifactId>
<version>${json-processing.version}</version>
<scope>provided</scope> <!-- or compile if your environment doesn't provide it -->
</dependency>
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-mapper</artifactId>
<version>${johnzon.version}</version>
</dependency>
The mapper module allows you to use the implementation you want of Json Processing specification to map Json to Object and the opposite.
final MySuperObject object = createObject(); final Mapper mapper = new MapperBuilder().build(); mapper.writeObject(object, outputStream); final MySuperObject otherObject = mapper.readObject(inputStream, MySuperObject.class);
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-jaxrs</artifactId>
<version>${johnzon.version}</version>
</dependency>
JAX-RS module provides two providers (and underlying MessageBodyReaders and MessageBodyWriters):