javajax-rsquarkusjsonb-api

Use Java records with JSON-B + Jax-RS


My project uses JSON-B with JAX-RS. The framework I am using is Quarkus and use Java 11. I tried to upgrade to Java 16 and use Java Records. It seems that JSON-B and Records does not work nicely.

I have tried @JsonbCreator. But this annotation only works with a single constructor.

I have also tried to use the Apache Johnzon as shown here (https://adambien.blog/roller/abien/entry/java_14_java_record_json). But Quarkus Resteasy does not have a Johnzon binding.

Is there a solution that would allow me to switch to Java Records?

Thanks


Solution

  • Quarkus uses Eclipse Yasson as its JSON-B implementation and currently Yasson does not support Records. However that will likely change soon, see this issue.

    If you are willing to move away from JSON-B, you can use Jackson with Quarkus and have Records support as Jackson supports them since version 2.12