users@glassfish.java.net

Re: how to switch between XML and JSON ?

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Sat, 3 Jan 2009 17:07:08 +0100

humm.. so, If I declare both languages, the client request will define
which one should be used in the response.. .. interesting.....

is there a way to establish a default ? the order ? or other...

On Sat, Jan 3, 2009 at 4:39 PM, heapifyman <heapifyman_at_gmail.com> wrote:
>
> 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
>>
>
>