Skip to content

Jackson 3 support: migrate jjwt-jackson to Jackson 3, add jjwt-jackson2 - #1085

Open
cspr0j wants to merge 5 commits into
jwtk:mainfrom
cspr0j:jackson3
Open

cspr0j wants to merge 5 commits into
jwtk:mainfrom
cspr0j:jackson3

Conversation

@cspr0j

@cspr0j cspr0j commented Nov 11, 2026

Copy link
Copy Markdown

Resolves #1029.

This follows the structure described by @lhazlewood in #1032:

  • jjwt-jackson now uses Jackson 3 (tools.jackson), so existing dependents are upgraded automatically.
  • The existing Jackson 2 implementation moves to a new jjwt-jackson2 module (package io.jsonwebtoken.jackson2.io).
  • Test cases are shared between both modules through a build-only jjwt-jackson-testkit module, not copied.

Behavior

A literal port changes the JSON JJWT writes and accepts, because Jackson 3 changed several defaults: java.util.Date values become ISO-8601 strings, enums are written with toString(), trailing content is rejected, and collection properties without setters are left empty. JJWT's default ObjectMapper therefore uses MapperBuilder#configureForJackson2(), so output and parsing are unchanged. Both modules pass the same shared tests, including 18 new ones that pin this behavior.

Build

  • Only extensions/jackson is compiled for Java 17; everything else still targets Java 8.
  • jjwt-impl's tests use jjwt-jackson2, so they still run on every JDK in the matrix.
  • The Jackson 3 module and the legacy jjwt jar skip the JDK 8 and 11 test legs. ci.yml is unchanged.

Verification

  • verify -Possrh -Dgpg.skip=true on JDK 17: all modules pass (1,816 tests).
  • -Dtest.jdk.version=8 on a Java 8 runtime: passes, with the two Java 17 modules skipped.
  • The Jackson 3 module's tests pass on Jackson 3.0.4, 3.1.8, 3.2.4 and 3.3.0.
  • Merges cleanly with the current 0.14.x branch (0.14.x #1059), and the combined build passes.

Questions for maintainers

  • The legacy jjwt jar follows jjwt-jackson and so now requires Java 17. Should it point at jjwt-jackson2 instead?
  • The test kit module sets the deploy-skip properties, but I could not test a release.
  • Happy to rebase onto 0.14.x if that is preferred over main.

Resolves jwtk#1029.  jjwt-jackson now uses Jackson 3 (tools.jackson), so
anyone already depending on it is upgraded automatically, while
jjwt-jackson2 remains available for Java 8 through 16 and Jackson 2
CHANGELOG (0.14.0): what changes for each kind of user, and the
backwards-incompatible consequences of jjwt-jackson requiring Java 17
and Jackson 3.

README: installation snippets, the JSON support overview, the Jackson
section (Jackson 3 ObjectMappers are never modified; reuse serializer
and deserializer instances), and a new Jackson 2 subsection.
@cspr0j

cspr0j commented Nov 11, 2026

Copy link
Copy Markdown
Author

Tested this branch in a real Spring Boot 4.1 service (Java 17, Jackson 3.1.5): existing tokens parse and the claims come out the same as before. I also compared it with 0.13.0 using a token with dates, large numbers, nested maps, lists and non-ASCII text: both versions produce byte-identical tokens and each parses the other's.

Comment thread bom/pom.xml
Comment on lines 67 to +76
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.14.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson2</artifactId>
<version>0.14.0-SNAPSHOT</version>
</dependency>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1

make the new module jjwt-jackson3 so we do not get a breaking change and WAY less diff.

@cspr0j cspr0j Nov 12, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this open for now. If the maintainers want a jjwt-jackson3 module I'll just switch it. See my comment below.

@bmarwell

Copy link
Copy Markdown
Contributor
  • Only extensions/jackson is compiled for Java 17; everything else still targets Java 8.

I hope @lhazlewood accepts this. The last time I tried this (JakartaEE jsonp/jsonb with Java 8 when the project was still Java 7), it was declined. I hope this will now be accepted. I'd vote for a new jackson3 module instead of re-using the old module for jackson 3 and copying the old jackson module to jackson2 so we do not get a breaking change. WDYT?

@cspr0j

cspr0j commented Nov 12, 2026 •

Copy link
Copy Markdown
Author

Thanks for looking!

I only went this way because that's what @lhazlewood asked for in #1032 (#1032 (comment)):

Additionally, I'd like the existing code in the jjwt-jackson module to be moved to a new jjwt-jackson2 module, and change the contents of the existing jjwt-jackson module to reflect the new Jackson 3 APIs.

This ensures that anyone already dependent on the jjwt-jackson module is upgraded automatically; we've seen more than a few projects just ignore or remain unaware of version upgrades otherwise.

A separate jackson3 module was already tried in #1032 and #1038, and as far as I can tell that comment is why they didn't go in.

I don't have a strong opinion on it myself. If the maintainers prefer jjwt-jackson3 I'll just switch it, it's mostly moving modules around.

Also agree with your point in the issue (#1029 (comment)) that dealing with two Jackson versions is a pain.

So maybe it's worth setting an end of support date for the Jackson 2 module, whichever name it ends up with.

@bmarwell

Copy link
Copy Markdown
Contributor

A separate jackson3 module was already tried in #1032 and #1038, and as far as I can tell that comment is why they didn't go in.

I can relate ;)

I don't have a strong opinion on it myself. If the maintainers prefer jjwt-jackson3 I'll just switch it, it's mostly moving modules around.

I see. I do think in breaking changes, and I just do not see why this would be more useful than the other way around, but in the end it does not matter too much. True.

Also agree with your point in the issue (#1029 (comment)) that dealing with two Jackson versions is a pain.

OH! Yeah but it is managable for some time for such a project.

So maybe it's worth setting an end of support date for the Jackson 2 module, whichever name it ends up with.

Great idea! I hope the maintainers agree!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adapter for Jackson 3.0

2 participants