// 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-unmarshalling-objects-in-native-mode"]
=== Marshaling / Unmarshalling objects in native mode

When marshaling / unmarshalling objects in native mode, their target types must be link:https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection[registered for reflection].

For example when using any of the following:

* `GsonDataFormat.setUnmarshalType(MyPojo.class)`
* `GsonDataFormat.setUnmarshalTypeName("org.acme.MyPojo")`
* `GsonDataFormat.setUnmarshalGenericType(MyPojo.class)`

`MyPojo.class` can be registered for reflection as follows.

[source,java]
----
package org.acme.MyPojo;

@RegisterForReflection
public class MyPojo {
}
----

