Hi,
I have a method like this:
@GET
@Path("competition/{comp}")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getTableXML(@PathParam("comp") String comp) throws
Exception {
LOG.debug("getTableXML()");
return Response.ok(findTableXML(comp)).build();
}
Jersey doesn¹t appear to automatically convert the xml to Json unless you
are using jaxb. I am not using jaxb so was wondering what the best approach
was for this in Jersey. I¹ve looked at some of the jackson classes I thought
about maybe using an ObjectMapper but again that appears to only be for use
with POJOs.
Another alternative is to implement my own MessageBodyWriter using one of
the many json libraries out there, currently thinking jsonlib which lets you
do something like:
XMLSerializer xmlSerializer = new XMLSerializer();
JSON json = xmlSerializer.read(xml);
StringWriter writer = new StringWriter();
json.write(writer);
return writer.toString();
But I was wondering if there was something nicer/neater already in Jersey?
Thanks
Jon