Hmm, I didn't used it until now, but from my point of view, I would *like*
an API like this one:

JettisonDataFormat jaxbObjectToJsonString = new JettisonDataFormat();
jaxbObjectToJsonString.set...

from("direct:start")
  .marshall(jaxbObjectToJsonString)
  .to("mock:end");

If you think this too, please open a JIRA for it...

Best,
Christian

On Tue, May 8, 2012 at 4:41 PM, Eugeniu <[email protected]> wrote:

> Hi Christian
>
> I used the jettison library shipped with the jaxrs implementation.
>
> Here you can find some more information:
> http://jersey.java.net/nonav/documentation/latest/json.html
>
> This is a link for the library: http://jettison.codehaus.org/Download
>
> And this is a marshal method I used to create a json string from my
> annotated JAXB java class:
>
>    public void marshal(Exchange ex) throws JAXBException {
>        Configuration conf = new Configuration();
>        MappedNamespaceConvention mnc = new MappedNamespaceConvention(conf);
>        Writer writer = new StringWriter();
>        XMLStreamWriter xmlStreamWriter = new MappedXMLStreamWriter(mnc,
> writer);
>        Object obj = ex.getIn().getBody();
>        JAXBContext jc = JAXBContext.newInstance(obj.getClass());
>        Marshaller marshaller = jc.createMarshaller();
>        marshaller.marshal(obj, xmlStreamWriter);
>        String json = writer.toString();
>        ex.getIn().setBody(json);
>    }
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Configure-json-to-use-jaxb-annotations-tp5687484p5694966.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to