users@glassfish.java.net

Re: how to switch between XML and JSON ?

From: heapifyman <heapifyman_at_gmail.com>
Date: Sat, 3 Jan 2009 16:39:30 +0100

The client has to set the ACCEPT header to JSON and only JSON, I
suppose.

Am 28.12.2008 um 17:41 schrieb Felipe Gaścho:

> 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;
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>