// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
= Gson
:page-aliases: extensions/gson.adoc
:linkattrs:
:cq-artifact-id: camel-quarkus-gson
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Marshal POJOs to JSON and back using Gson
:cq-deprecated: false
:cq-jvm-since: 1.0.0
:cq-native-since: 1.0.0

[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##1.0.0##

Marshal POJOs to JSON and back using Gson

== What's inside

* xref:{cq-camel-components}:dataformats:gson-dataformat.adoc[JSON Gson data format]

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

== Maven coordinates

https://code.quarkus.io/?extension-search=camel-quarkus-gson[Create a new project with this extension on code.quarkus.io, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-gson</artifactId>
</dependency>
----

Check the xref:user-guide/index.adoc[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 link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[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 link:https://github.com/apache/camel-quarkus/blob/main/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/PojoA.java[integration test].

