users@glassfish.java.net

how to switch between XML and JSON ?

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Sun, 28 Dec 2008 17:41:10 +0100

I have a method annotated to produce both XML or JSON contents.. how
do I switch between them ? what is the URL suffix I must add to my
resource URL ??

For example:

http://fgaucho.dyndns.org:8080/footprint-service/admin/config/123

This returns an XML (because the JAXBElement is being automatically
unmarshalled to XML ).. how do I read it as JSON string ??

* the fragment of code I am using as example:

        @GET
        @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
        public JAXBElement<FootprintConfig> get(@PathParam("config_id") String id) {
                JAXBElement<FootprintConfig> jbe = factory.createConfiguration(factory
                                .createFootprintConfig());
                return jbe;
        }