I would like to format my gson when the json object came via Apache-Camel context. In my application_context.xml related field is like this:
<camel:camelContext>
<camel:dataFormats>
<camel:json id="gson" library="Gson" unmarshalTypeName="com.pzt.blz.fraud.domain.Payment" />
</camel:dataFormats>
<camel:route>
<camel:from uri="rabbitmq::blz.service.component.fraud?autodelete=false&durable=true"/>
<camel:unmarshal ref="gson"></camel:unmarshal>
<camel:process ref="fraudProccessor"></camel:process>
<camel:marshal ref="gson"></camel:marshal>
<camel:inOnly uri="rabbitmq::blz.service.component.fraud-reply?autodelete=false&durable=true"/>
</camel:route>
</camel:camelContext>
Camel:unmarshal and Camel:marshal parts are doing the json to object and vice versa thing.However I would like to add some properties on this file like:
public Gson createGson(){
return new GsonBuilder().
setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).
setPrettyPrinting().
serializeNulls().
create();
}
How can I setFieldNamingPolicy to LOWER_CASE_WITH_UNDERSCORES or LOWER_CASE_WITH_DASHES etc...
Is there any chance to format this on Camel? and these changes should be done at my application_context.xml file.
Appreciate for all replies...