users@jersey.java.net

Re: [Jersey] Json output not always matching xml output

From: Paul Taylor <paul_t100_at_fastmail.fm>
Date: Wed, 18 Nov 2009 19:07:57 +0000

Jakub Podlesak wrote:
> Hi Paul,
>
> It turns out, JAXB runtime does not provide correct information
> on the score attribute in this (unfortunate xs:anyAttribute) case.
> I am not sure this could be fixed easily, but you can try using the following
> JSON configuration as a workaround:
>
> return new JSONJAXBContext(
> JSONConfiguration
> .mapped()
> .attributeAsElement("score")
> .arrays("release-group")
> // comment this out, if you want to get string "50" instead of number 50
> .nonStrings("score")
> .build(),
> "org.musicbrainz.mmd2");
>
> in the initJsonContext method.
>
> Which gives me:
>
> {"release-group-list":{"release-group":[{"score":50},{"score":50},{"score":50},{"score":50},{"score":50}]}}
>
> HTH,
>
> ~Jakub
Right, so are you saying there is a bug/omission in JAXB or just that
Jersey depends on extra information that JAXB doesnt have , and never
will do because its not required by JAXB.

Am I doing something wrong, should I been amending the xml that the
classes are derived from ?

Paul