Sneak Peek at Jackson 2.13

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

Bigger Changes 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

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

  • 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

# 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

  • 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?

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
@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