> -----Original Message-----
> From: Sergey Beryozkin [mailto:[email protected]]
> Sent: Friday, October 02, 2009 9:26 AM
> To: [email protected]
> Subject: Re: How to make clean json, instead of xml-ish json?
>
> Hi,
>
> CXF Jettison based provider can be asked to drop a root element so
it's
> easy to get rid of the root Item wrapper.
How is that done, exactly?
> This is obviously a convention that Jackson drops it be default. Note
> that a JAXRS client won't be able to read a rootless sequence,
> for example when testing a service with a client api, so such a
> sequence is handy when using some JSON utilities which expect no
> root, etc. CXF JSONProvider can actually be asked to 'append' a root
> element to an incoming rootless sequence.
I had realized that rootless JSON might have issues when unmarshalling
back into Java. At this point, that's not an issue for me, but I'll
reexamine this if it ever does.
> The next thing is that CXF produces this JSON (lets assume a root
> element has been dropped, the ordering can be handled with no
> probs by JAXB) :
>
>
{"description":"abc","features":[{"feature":[123,124]}],"id":1,"title":
> "item"}
In typical JSON usage, ordering of the properties of a single object is
not meaningful, except for cosmetic reasons.
> Jackson produces a simpler and possibly more JSON-y (not sure if it
> sounds correct :-)) sequence, but again you can't read with the
> client api (unmarshall into an expected bean - though may be Jackson
> can do but I'll be surprised). With CXF it will be possible
> soon enough to configure it to 'massage' the output sequence as needed
> for JSON be easily consumed by say a running javascript
> client but still allow for a jaxrs client to test the endpoint.
I'll be willing to examine this when it becomes available.
> Note myself and Dejan (Jettison mantainer) are planning to put some
> effort into making Jettison a bit more robust but it will not
> likely to happen in the short term
Good to hear.