camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Webb <elihusma...@gmail.com>
Subject custom converter to string (json, xml, csv)
Date Fri, 17 Oct 2014 18:50:29 GMT
I have a custom object that I will be passing through Camel routes and
there may be times where I want to convert the object to different formats,
which means that I need to write custom converters.  My question is, how do
I write a converter for the different String-based formats such as JSON,
XML and CSV and have Camel be smart enough to choose the correct one?

If I have the following methods

@Converter
public String myObjectToXml( MyObject event ){
// do stuff here
        return "<xml>junk</xml>";
}

@Converter
public String myObjectToJson( MyObject event ){
// do stuff here
        return "{stuff:junk}";
}

@Converter
public String myObjectToCsv( MyObject event ){
// do stuff here
        return "junk,blah";
}

So I would marshal the object to a String-based format, but how does Camel
know which one I want?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message