0

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&amp;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&amp;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...

1 Answer 1

0

I don't think we have exposes those options in the XML DSL so you can configure this on the gson data format. I have logged a ticket to implement this in a future Camel release: https://issues.apache.org/jira/browse/CAMEL-6227

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.