users@jersey.java.net

Re: [Jersey] Re: jersey json to jaxb

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Fri, 14 May 2010 10:41:58 +0200

Hi Emile,

I see two issues at your files (have not tested anything).

The first one relates to the allRecipients attribute:

    1) if you do not want to use any special configuration option (see
[1] for details), you would need to mark it with @ prefix

    2) JAXB based JSON processing goes via XML infoset intermediary even
for JSON data.
        Then, the attribute must come first!

The second one relates to the actual value at the workflowComments tag,
where you would need to use "$" instead
of just "value" as the identifier (this is a must and could not be
reconfigured at the moment).

The following could work for you:

{"processDetails": {
  "workflowName": "tstwfname",
  "packageObjects": {
    "packageId": [
      "090004d080011d6c"
    ]
  },
  "supportingObjects": {
    "supportingId": [
      "090004d080011d6d"
    ]
  },
  "workflowComments": {
    "@allRecipients": true,
    "$": "Workflow comments test 122"
  },
  "supervisorName": "dmadmin"
}}


If you want to be 100 % sure, the best way would always be to get some
data serialized out first from Java
and then see what you get.

If you do not want to bother with the JAXB based JSON processing, you
could also utilize the Jackson providers.
(The XML part will still be taken care of by JAXB)

See example [2] to see how to register the Jackson providers at your
application (look at the META-INF/services subdirectory).

HTH,

~Jakub

[1]https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html#d4e798
[2]http://download.java.net/maven/2/com/sun/jersey/samples/jacksonjsonprovider/1.2/jacksonjsonprovider-1.2-project.zip


emile wrote:
> Hi,
>
> Does anyone have any pointers on what might be wrong here? please do help me
> out.
>
> TIA,
> Emile.
>