Migrating a module to Jakarta JSON is most of the time a well-defined task.
First, remove any old javax.json
dependencies:
org.apache.sling:org.apache.sling.commons.johnzon:1.*
org.apache.geronimo.specs:geronimo-json_1.1_spec
org.apache.geronimo.specs:geronimo-json_1.0_spec
Then, add the new jakarta.json
dependencies. Generally it is recommended to add the latest 2.* version of org.apache.sling:org.apache.sling.commons.johnzon
.
The only known exception is when testing libraries, like the Sling Mocks, bring in 1.x versions of Johnzon in the classpath. This leads to runtime conflicts and therefore different dependencies need to be used for the Jakarta JSON API and implementation. The following are known to work well:
jakarta.json:jakarta.json-api:2.0.2
org.glassfish:jakarta.json:2.0.1