dev@jersey.java.net

Using JAXB for JSON and XML with one HTTP method

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 07 Aug 2007 16:33:15 +0200

Hi,

I just committed a fix for the latest build so one can do the following:

@UriTemplate("/")
public class MyResource {
    @HttpMethod
    @ProduceMime({"application/xml", "application/json"})
    public JAXBBean get() {
       JAXBBean j = ...
       return j;
    }
}

If there is no accept header or the accept is "*", "application/*" or
"application/xml" then the JAXB bean will be serialized as XML. If the
accept header is "application/json" then the JAXB bean will be
serialized as JSON (as per the modifications made by Jakub to the JAXB
element entity provider).

Unit tests pass so it should work... :-)

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109