users@jersey.java.net

java to json and back

From: Pedro Teixeira <pedro.t_at_gmail.com>
Date: Tue, 20 Jan 2009 01:55:27 -0200

Hello,

Can anyone point to the standard/best practice to marshal data between json
and java?

So far, I am keeping my method's arguments and return types as plain String,
but that implies a 'boring' layer of manual serialization.

I'm currently experimenting with the following APIs:
- flexjson (best so far java to json, but could not get Deserializer to work
yet)
- json-lib http://json-lib.sourceforge.net/
- http://code.google.com/p/json-simple/

The problem is a bit harder from json to java. Is there any API to copy
properties in an existing java instance?

Is there a better way? Should I really be looking in generating extra
temporary java structures to use with JAXB? (want to avoid and it seems that
JAXB produces strange looking json). I don't expect any magic from Jersey's
implementation, but I just would like to check how's the community dealing
with the engineering of (un)marshalling complex objetcs in large systems.

Currently trying to decise if simple/boring code is better than spending
time with mega-extra dynamics/reflections (that will not suit all cases).


regards,
Pedro