【发布时间】:2013-03-28 15:36:48
【问题描述】:
当 json 对象来自 Apache-Camel 上下文时,我想格式化我的 gson。在我的 application_context.xml 中相关字段是这样的:
<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 和 Camel:marshal 部分正在对对象执行 json,反之亦然。但是我想在此文件上添加一些属性,例如:
public Gson createGson(){
return new GsonBuilder().
setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).
setPrettyPrinting().
serializeNulls().
create();
}
如何将FieldNamingPolicy 设置为 LOWER_CASE_WITH_UNDERSCORES 或 LOWER_CASE_WITH_DASHES 等...
有没有机会在骆驼上格式化这个?这些更改应该在我的 application_context.xml 文件中完成。
感谢所有回复...
【问题讨论】:
标签: json spring apache gson apache-camel