I'm stuck with camel documentation as it's not very clear...
I want to define this route in Spring :
in: direct access from a url
out: get an object instance from a factory
--> format this object in Json
I've tried with marshaller like this :
<camel:route id="viewObject">
<camel:from uri="restlet:/json/" />
<camel:to uri="bean:myFactory" />
<camel:unmarshal ref="jack" />
</camel:route>
but it doesn't work as the unmarshal works after input and before output, this was expected so I tried to re route the output to another endpoint.
<camel:route id="formatObject">
<camel:from uri="bean:myFactory" />
<camel:unmarshal ref="jack" />
<camel:to uri="mock:reverse" />
</camel:route>
Basically I want my object :
public class MyObject{
private String name;
[ getter & setter here]
}
to be unmarshalled this way :
{name : 'a value'}
And this only with marshaller and camel config. Please help, crystal clear explanations and howtos are welcomed too
Essentially, just create xml like this inside your camel context.
<dataFormats>
<json id="jack" library="Jackson" unmarshalTypeName="com.example.MyObject"/>
</dataFormats>
<route>
<from uri="restlet:/json/"/>
<to uri="bean:myFactory"/>
<marshal ref="jack"/>
</route>
You seem to have mixed up the marshall/unmarshall words
Unmarshall = from json -> bean Marshall = from bean -> json.