Gson

JVM since1.0.0 Native since1.0.0

Marshal POJOs to JSON and back using Gson

What’s inside

Please refer to the above link for usage and configuration details.

Maven coordinates

Or add the coordinates to your existing project:

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-gson</artifactId>
</dependency>

Check the User guide for more information about writing Camel Quarkus applications.

Additional Camel Quarkus configuration

Marshaling/Unmarshaling objects in native mode

When marshaling/unmarshaling objects in native mode, all the serialized classes need to be registered for reflection. As such, when using GsonDataFormat.setUnmarshalType(…​), GsonDataFormat.setUnmarshalTypeName(…​) and even GsonDataFormat.setUnmarshalGenericType(…​), the unmarshal type as well as sub field types should be registered for reflection. See a working example in this integration test.