[英]Automatically marshall JSON in Camel
Apache camel seems to be quite happy marshalling JAXB annotated classes, eg: Apache骆驼整理JAXB注释的类似乎很高兴,例如:
@XmlRootElement(name = "authPlayerRequest")
public class AuthPlayerRequest {
@XmlElement(required = true)
protected Player player;
}
If this is on a servlet://...
route then this works just fine. 如果这是在servlet://...
路由上,则可以正常工作。
However... I want JSON. 但是...我想要JSON。 This does not appear to work automatically and I cannot figure out how to get it to work. 这似乎无法自动工作,我无法弄清楚如何使其工作。
How can I get it to work? 我如何使它工作?
You need to declare the JSON handler and sometimes give it a hint to the annotated class. 您需要声明JSON处理程序,有时还向带注释的类提供提示。
<dataFormats>
<json id="pojo" library="Jackson" unmarshalTypeName="com.co.Pojo"/>
</dataFormats>
<route id="myRouteUsingJson">
<from uri="..." />
<unmarshal ref="pojo" />
<bean ref="myClassThatNeedAPojo" method="doStuffPojoAsParameter" />
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.