jjwt icon indicating copy to clipboard operation
jjwt copied to clipboard

[#719] JSON-B extension.

Open bmarwell opened this issue 3 years ago • 4 comments

Fixes #719:

This commit will add a JSON-B extension based on JSON-B specification 1.0.2.

Noteworthy

  • Since this specification uses Java 8 features (static methods in interfaces), the property jdk.version was set to 8.
  • Since we now use Java 8, there is little advantage in using custom assertions, this null input is validated by java.util.Objcets.requireNonNull and will throw a NullPointerException (which makes more sense anyway) instead of an IllegalArgumentException.
  • Instead of Strings.UTF_8 the JDK8-included StandardCharsets.UTF_8 was used.
  • I used Johnzon for testing, but only because it is an Apache project. It should work with Eclipse Yasson without any changes. If desirable, I could implement a maven profile for this – or even better, an IT project (e.g. intergation-tests/json/jsonb-yasson and intergation-tests/json/jsonb-sth-else).
  • The (provided) dependency on json-api (aka json-p for JSON-Parser) is needed at least for Johnzon, but probably for some Exceptions as well. Johnzon fails because javax.json.JsonException is missing. But since json-api/json-p is a transitive dependency for json-bind-api (json-b) as well, this should be okay.

Other notes

  • The provided scope is because of JakarteEE Application Server usage. Tested on OpenLiberty. But for JavaSE apps, users of this lib would need to include those by hand, as well as the implementation. This should go into the README.

Tasks

  • [X] Added implementation.
  • [X] README.md updated.
  • [X] Added notice about JavaSE vs JakartaEE environments and their ([not-]provided) dependencies.
  • [X] Added "when-to-use" note.

bmarwell avatar Apr 15 '22 19:04 bmarwell

Great work!

bdemers avatar Apr 18 '22 17:04 bdemers

Oh, shouldn’t the profile name be "nonJDK7"? And did I, by accident, not rebase the PR?

bmarwell avatar Apr 19 '22 19:04 bmarwell

good point, java8plus, nonJDK7 or something like that would work

bdemers avatar Apr 19 '22 20:04 bdemers

good point, java8plus, nonJDK7 or something like that would work

Nah you already have "nonJDK7" in your root-pom.xml. I will rebase this PR later when I have a first version of my modules-PR available. I finished it yesterday evening but didn’t push it yet, just a moment.

bmarwell avatar Apr 20 '22 09:04 bmarwell