users@jersey.java.net

Re: [Jersey] JSONP Callback support

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Wed, 04 Feb 2009 09:58:34 -0500

Jakub Podlesak wrote:
> On Wed, Feb 04, 2009 at 11:30:21AM +0100, Paul Sandoz wrote:
>
> <snip/>
>
>
>>> The use of '@' sign in resulting JSON as described by BadgerFish is
>>> causing a downstream problem for me as the toolkit I am using to process
>>> JSON does not like it. So I need to fix my ResponseFilter to remove '@'
>>> sign in the JSON output.
>>>
>
> You do not need to filter '@' out using ResponseFilter,
> please see [1] for two options how to get rid of '@' and still
> retain possibility to de-serialize the JSON back to Java.
>

I created a class as follows using NATURAL notation and am using latest
svn bit for 1.0.2-SNAPSHOT.
I am still getting getting '@' chars in field names. Do I need to do
something else in terms of configuration
to tell jersey runtime to use this Provider (I am guessing that is what
@Provider annotation is already doing).

Any idea what I could be missing?

Note I am using a contextPath rather than specific classes which is
morer tedious to do.


@Provider
public final class JAXBContextResolver implements
ContextResolver<JAXBContext> {

    private final JAXBContext context;

    public JAXBContextResolver() throws Exception {
        this.context = new JSONJAXBContext(
            
JSONConfiguration.getBuilder(JSONConfiguration.Notation.NATURAL).build(),
BindingUtility.jaxbContextPath);
    }

    public JAXBContext getContext(Class<?> objectType) {
        return context;
    }
}


Thanks very much for all you help.

-- 
Regards,
Farrukh
Web: http://www.wellfleetsoftware.com