Skip to content

Commit 5d094fa

Browse files
authored
Merge pull request #46182 from rolfedh/add-jackson-deserializer-info
Add reflection-free Jackson deserialization to guide
2 parents 71ab441 + 6da8fee commit 5d094fa

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

docs/src/main/asciidoc/rest.adoc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,11 +1627,26 @@ public User userPrivate() {
16271627
When the result the `userPublic` method is serialized, the `id` field will not be contained in the response as the `Public` view does not include it.
16281628
The result of `userPrivate` however will include the `id` as expected when serialized.
16291629

1630-
===== Reflection-free Jackson serialization
1630+
===== Reflection-free Jackson serialization and deserialization
16311631

1632-
Out-of-the-box Jackson serialization converts objects into their JSON representation by introspecting them through a heavy use of reflection. However, the general Quarkus philosophy is to avoid reflection as much as possible, often replacing it with build time code generation. For this reason it is possible to automatically generate at build time implementations of the Jackson `StdSerializer`, one for each class to be converted in JSON. These generated serializers can be subsequently used by Quarkus at runtime to perform the JSON serialization of the objects returned by a REST endpoint without any use of reflection.
1632+
By default, Jackson uses reflection to convert objects to and from JSON.
1633+
However, {project-name} follows a build-time optimization philosophy.
1634+
To align with this approach, configure your application to minimize reflection by using the link:https://quarkus.io/extensions/io.quarkus/quarkus-rest-jackson[`quarkus-rest-jackson`] extension.
16331635

1634-
This feature is turned off by default, but it can be enabled by setting the configuration property `quarkus.rest.jackson.optimization.enable-reflection-free-serializers=true`.
1636+
This feature is introduced as a Technology Preview and is disabled by default.
1637+
1638+
By eliminating reliance on reflection during deserialization, applications can achieve better performance and reduced memory consumption, particularly for native applications where reflection can introduce overhead.
1639+
If you implement this feature, run tests to assess its effect on your applications.
1640+
1641+
To enable this feature, set the following configuration property to `true`:
1642+
1643+
`quarkus.rest.jackson.optimization.enable-reflection-free-serializers=true`.
1644+
1645+
Setting this property applies reflection-free optimization to deserialization and serialization.
1646+
1647+
When enabled, {project-name} generates `StdSerializer` and `StdDeserializer` implementations at build time for each class requiring JSON conversion. The application then processes objects returned by REST endpoints using these generated serializers and deserializers, eliminating reliance on reflection and improving performance.
1648+
1649+
Developers can further customize JSON processing by implementing the `ObjectMapperCustomizer` interface. This interface allows fine-grained control over the `ObjectMapper`, enabling the registration of custom serializers and deserializers while ensuring compatibility with the reflection-free optimization. If additional configuration is needed, implement an `ObjectMapperCustomizer` bean and register any necessary modules or settings.
16351650

16361651
===== Completely customized per method serialization/deserialization
16371652

0 commit comments

Comments
 (0)