Getting started

Johnzon is modular: you add only the pieces you need. Every artifact lives on Maven Central under the groupId org.apache.johnzon.

  • Binding objects to JSON? Use johnzon-jsonb, the standard Jakarta JSON-B API. It pulls the mapper and the core parser transitively.
  • Streaming or tree parsing only? Use johnzon-core, the Jakarta JSON-P implementation on its own.
  • JAX-RS services? Add johnzon-jaxrs; it is the default JSON provider in Apache TomEE.

The API jars

Johnzon implements the Jakarta APIs but does not embed them. Add the API jars with scope provided when your runtime (an application server such as TomEE) already ships them, or compile when it does not:

<dependency>
    <groupId>jakarta.json</groupId>
    <artifactId>jakarta.json-api</artifactId>
    <version>2.1.3</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>jakarta.json.bind</groupId>
    <artifactId>jakarta.json.bind-api</artifactId>
    <version>3.0.0</version>
    <scope>provided</scope>
</dependency>

The jakarta.json-api jar hardcodes Parsson as its default JSON-P implementation. Where standard Java service loading is not possible, this can select the wrong provider. Make sure Johnzon is visible on the classpath through the usual ServiceLoader mechanism.

Choosing a version

JohnzonNamespaceImplementsPlatform
2.xjakarta.*JSON-P 2.1, JSON-B 3.0Jakarta EE 10+
1.3.x / 1.2.xjavax.*JSON-P 1.1, JSON-B 1.0Java EE 8

The 1.2.x artifacts are additionally published with a jakarta classifier, produced by bytecode transformation, for Jakarta EE 9 environments. See Download for release archives, signatures and older lines.

API reference

The Javadoc for the current release covers all modules.

Module documentation

  • Core (JSON-P) The Jakarta JSON Processing (JSON-P 2.1) implementation: streaming parser, generator, tree model.
  • Mapper Johnzon's object mapper: map Java objects to JSON and back over any JSON-P implementation.
  • JSON-B The Jakarta JSON Binding (JSON-B 3.0) implementation, built on the Johnzon mapper.
  • JAX-RS JAX-RS providers (MessageBodyReader/Writer) for JSON, used by Apache TomEE as its default JSON provider.
  • WebSocket Encoders and decoders integrating JSON-P, the mapper and JSON-B with the Java WebSocket API (JSR 356).
  • Extras JSON Schema validation, JSON Logic, JSON-B extensions and OSGi integration.