Sneak Peek at Jackson 2.13

@cowtowncoder
5 min readAug 31, 2021

--

While the final Jackson 2.13.0 is not yet out — there are, however, two release candidates, 2.13.0-rc1 and 2.13.0-rc2 — it’s a good time to check out what will be included.

2.13: a bit smaller release again

First things first: whereas Jackson 2.12 release was stock full of new features, 2.13 was planned to be a more modest update: focusing on just one or two bigger things. This is what is happening. The other part of the plan — get it out much quicker — did not quite pan out, partly due to need to patch some of the gaps in new functionality that 2.12 provided; and partly due to my having a bit less time to spend on pro bono OSS development.
The upside, I hope, is that 2.13.0 will be the most stable new minor release in years, thanks to longer Release Candidate phase and smaller set of new features.

Bigger Changes in 2.13

There are 3 bigger things included in 2.13:

  1. Baseline JDK is now JDK 8 — not just for building but also running.
  2. Full set of “Jakarta” modules to (eventually) replace “JAX”/”Javax” modules (for background, search for “jakarta vs javax”, and read f.ex “Jakarta EE Without javax: The World Won’t End This Time Either”) — replaces 2.12-only Maven classifier approach used for JAX-RS
  3. New dataformat module for reading/writing TOML: jackson-dataformat-toml

Jackson 2.13: Now Java8 only

This may not seem like a big deal, but for the longest time JDK baseline was kept at lower versions — it was, at least in theory, possible to use jackson-databind on Java 7 SE platform (and basic streaming on Java 6).

2.13 release increases the baseline to Java 8 (you need Java 8 to use most Jackson functionality), with the exception of two packages (jackson-core (core streaming for JSON, API) and jackson-annotations).
This is good for Jackson core developers since:

  1. It is possible to reduce code differences between Jackson 2.x and upcoming 3.x (from master branch) — 3.x was already Java 8 based
  2. Cleaner 2.x APIs for Builder-style configuration
  3. Ability to use cleaner Java 8 code constructs where applicable
  4. Possibly embed one of Java 8 modules (Optional support, Construct parameter name detection) for later 2.x versions (not yet embedded in 2.13)

although may be limiting on some very old platforms. Still, it is time to move on.

Full set of Jakarta modules to replace JAX/Javax (Java EE) modules

A “royal mess” that is known as the transition from Java EE to Jakarta EE — explained in some detail by Eclipse org — has big consequences to 3 Jackson modules, which supported former “JAX*” (or “javax”) APIs:

  • JAXB annotation support module
  • JAX-RS providers (for Jersey et al)
  • JSON-P (JSR-353) datatype module

In each case we have a module (or in case of JAX-RS, modules) that implemented one of Java EE APIs; ones that are fully renamed and repackaged to become parts of Jakarta set of APIs. Although some tooling has been developed to try to automatically change implementations on the fly (or during packaging or publishing), Jackson project decided it makes more sense to fork existing modules and create a full set of replacements with different packages (Java, Maven) and module (JPMS). This way downstream dependencies will explicitly indicate which implementations to use, based on Specification they support.
For example: older versions of Jersey would use existing “-jaxrs” provider modules, and newer (Jakarta-based) will use “-jakarta-rs” providers.

With that, mappings are:

It is also worth noting that Jackson 2.12 attempted to support “Jakarta variant” for JAX/Jakarta-RS using Maven classifier concept (classifier “jakarta”), generated from a single source repo. This approach did not fully work, unfortunately (issues with module info description), and is no longer supported.

Support for TOML with jackson-dataformat-toml

In addition to the extensive textual format support Jackson has (for CSV, XML, YAML and Java Properties), there is now even official support for TOML format (“Tom’s Obvious Minimal Language”) which is used as a configuration file format and considered by many to be a “less confusing alternative to YAML” (where “Norway is not false!”).
An example of TOML configuration, from its official web site shows typical usage:

# This is a TOML document

title = "TOML Example"

[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00

and it could be thought of as logically equivalent to JSON like

{
"title" : "TOML Example",
"owner" : {
"name" : "Tom Preston-Werner",
"dob" : "1979-05-27T07:32:00-08:00"
}
}

(considering with native date/time type(s)).

At this point module fully supports TOML version 1.0 for reading and all the usual Jackson functionality (read into POJOs, as JsonNode, use streaming access).
It can also write TOML although at this point output will “look ugly”, similar to Java Properties output — however, it will still be valid TOML with logically equivalent content. Just not pretty.

Given that this is the first minor version with official support there may be rough edges, but so far the feedback has been cautiously positive and at least one framework already uses pre-release version from Jackson 2.12.4.

Other notable inclusions in 2.13

Aside from above-mentioned “big 3” there are over 70 assorted changes, from bug fixes to minor new functionality (see the work-in-progress 2.13 Release Notes for full details). Highlights include:

  • New “No-Constructor module” — jackson-module-no-ctor-deser — with which Jackson can force instantiation of POJOs without 0-argument constructor (see module README for details)
  • Improved reporting of JsonLocation for low-level parsing exceptions: offsets for binary content, and content snippet only for textual formats (no more garbage “source” included). Multiple issues fixed, see jackson-core#694 (for example)
  • For XML, ToXmlGenerator.Feature.UNWRAP_ROOT_OBJECT_NODE to avoid writing extra wrapper <ObjectNode> wrapper (see dataformat-xml#441 for details)
  • For Avro, some support for “Logical Types” (Java 8 date/time types) (see dataformat-avro#283 for details)

What else?

For the full set of all changes included, please see 2.13 Release Notes page (work-in-progress). Now would be good time to check out upcoming functionality if you are using Jackson 2.12: version 2.13.0-rc2 was just released and all the help with regression testing would be most welcome!

--

--

@cowtowncoder

Open Source developer, most known for Jackson data processor (nee “JSON library”), author of many, many other OSS libraries for Java, from ClassMate to Woodstox