users@jersey.java.net

Re: [Jersey] Can I suppress adding of _at_'s for attributes when generataing JSON from JAXB

From: Paul Taylor <paul_t100_at_fastmail.fm>
Date: Fri, 06 Nov 2009 11:43:49 +0000

Paul Taylor wrote:
> Using defaults I get:
>
> {"artist-list":{"@offset":"0","@count":"1","artist":{"@type":"group","@id":"8538e728-ca0b-4321-b7e5-cff6565dd4c0","@score":"100","name":
>
> "Depeche Mode","sort-name":"Depeche
> Mode","life-span":{"begin":"1980"},"alias-list":{"alias":"Depech
> Mode"}}}}
>
> but I've been asked for:
>
> {"artist-list":{"offset":"0","count":"1","artist":{"type":"group","id":"8538e728-ca0b-4321-b7e5-cff6565dd4c0","score":"100","name":
>
> "Depeche Mode","sort-name":"Depeche
> Mode","life-span":{"begin":"1980"},"alias-list":{"alias":"Depech
> Mode"}}}}
>
> Is there something I can change in my JSON configuration to do this.
>
> thanks Paul

FYI, using natural() rather than mapped() solves the issue

i.e return new JSONJAXBContext(JSONConfiguration.natural().build(),
            "org.musicbrainz.mmd2");

might help if this difference was shown in the examples in
https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/json/JSONConfiguration.Notation.html