users@jersey.java.net

Re: [Jersey] Differentiating content

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 05 Mar 2010 14:31:21 +0100

On Mar 5, 2010, at 11:33 AM, emile wrote:

>
> Hi,
>
> A newbie question - I have a resource that consumes both JSON and
> XML, how i
> differentiate the content passed?
>
> @POST
> @Consumes({"application/xml", "application/json"})
> public String getObjectAsXML(Document doc)
>

Use two different methods:

    @POST
    @Consumes("application/xml")
     public String getObjectAsXML(Document doc) { ... }

    @POST
    @Consumes("application/json")
     public String getObjectAsXML(JSONObject o) { ... }

Paul.

> Thanks in Advance!
> --
> View this message in context: http://n2.nabble.com/Differentiating-content-tp4680061p4680061.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>