// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-gson"]
= 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

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##1.0.0##
endif::[]

Marshal POJOs to JSON and back using Gson

[id="extensions-gson-whats-inside"]
== 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.

[id="extensions-gson-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-gson[Create a new project with this extension on {link-quarkus-code-generator}, 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>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-gson-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration

[id="extensions-gson-configuration-marshaling-unmarshaling-objects-in-native-mode"]
=== 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].

