I think it's a limitation of the underlying JSON library. Something like:
@XmlRootElement
public class Foo {
@XmlElementWrapper(name="values")
@XmlElement(name="value")
private List<String> values
}
Gives XML like:
<foo>
<values>
<value>foo</value>
<value>bar</value>
</values>
</foo>
And json like:
{foo: {values: {value: ["foo", "bar"]}}}
Whereas really, if this is an API that you want to publicize, you really want:
{values: ["foo", "bar"]}
Seems like the JSON is generated via JAXB and an XMLStreamWriter, which
unfortunately is too limited to provide real control over the JSON.
Thanks,
Gary
-----Original Message-----
From: Sergey Beryozkin [mailto:[email protected]]
Sent: 10 February 2009 10:48
To: [email protected]
Subject: Re: JSON in CXF
Hi Gary
> JSON via JAXB definitely leaves something to be desired.
Do you reckon it's the limitations of the underlying JSON library that we use
(Jettison) or do you refer to the insufficient number of hooks for our JSON
JAXRS reader/writer whiich would help in producing a better quality JSON ?
Can you post some examples please - I hope it will help us to improve what we
have
Thanks, Sergey
Hi guys,
I really like how CXF provides both JSON and XML out of the box. However,
after working with the JSON serializer a bit, it's obvious that the JAXB
annotations translate poorly to JSON, and that while you have great control
over XML via JAXB, JSON via JAXB definitely leaves something to be desired.
Do you guys know of any jaxb-quality, annotation-driven JSON serializers?
Cheers,
Gary
--------------------------------------------------------------------------
This is not an offer (or solicitation of an offer) to buy/sell the
securities/instruments mentioned or an official confirmation.
Morgan Stanley may deal as principal in or own or act as market maker for
securities/instruments mentioned or may advise the issuers. This is not
research and is not from MS Research but it may refer to a research
analyst/research report. Unless indicated, these views are the author's and may
differ from those of Morgan Stanley research or others in the Firm. We do not
represent this is accurate or complete and we may not update this. Past
performance is not indicative of future returns. For additional information,
research reports and important disclosures, contact me or see
https://secure.ms.com/servlet/cls. You should not use e-mail to request,
authorize or effect the purchase or sale of any security or instrument, to send
transfer instructions, or to effect any other transactions. We cannot guarantee
that any such requests received via e-mail will be processed in a timely
manner. This communication is solely for the addressee(s) and may contain
confidential information. We do not waive confidentiality by mistransmission.
Contact me if you do not wish to receive these communications. In the UK, this
communication is directed in the UK to those persons who are professional and
eligible counterparties (as defined in the UK Financial Services Authority's
rules).
--------------------------------------------------------------------------
This is not an offer (or solicitation of an offer) to buy/sell the
securities/instruments mentioned or an official confirmation. Morgan Stanley
may deal as principal in or own or act as market maker for
securities/instruments mentioned or may advise the issuers. This is not
research and is not from MS Research but it may refer to a research
analyst/research report. Unless indicated, these views are the author’s and may
differ from those of Morgan Stanley research or others in the Firm. We do not
represent this is accurate or complete and we may not update this. Past
performance is not indicative of future returns. For additional information,
research reports and important disclosures, contact me or see
https://secure.ms.com/servlet/cls. You should not use e-mail to request,
authorize or effect the purchase or sale of any security or instrument, to send
transfer instructions, or to effect any other transactions. We cannot guarantee
that any such requests received via e-mail will be processed in a timely
manner. This communication is solely for the addressee(s) and may contain
confidential information. We do not waive confidentiality by mistransmission.
Contact me if you do not wish to receive these communications. In the UK, this
communication is directed in the UK to those persons who are professional and
eligible counterparties (as defined in the UK Financial Services Authority’s
rules).