cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <>
Subject Re: JSON in CXF
Date Tue, 07 Apr 2009 11:14:00 GMT
Hi Gary

> If you give me until next week I should be able to package something together and send
it to you.
it would be super, take your time please...

> Rewriting Sun libraries?  Working with JSON?  Hells yeah.

that's the right attitude :-).

cheers, Sergey

----- Original Message ----- 
From: "Tong, Gary (IDEAS)" <>
To: <>
Sent: Tuesday, April 07, 2009 8:53 AM
Subject: RE: JSON in CXF

Hi Sergey,

If you give me until next week I should be able to package something together and send it
to you.

Alternatively, this would be a great project for GSoC, if it's not too late to submit projects.
 Rewriting Sun libraries?  Working 
with JSON?  Hells yeah.


-----Original Message-----
From: Sergey Beryozkin []
Sent: 06 April 2009 12:01
Subject: Re: JSON in CXF

Hi Gary
>> I ended up writing my own converter for JSON that uses its own
>> annotations seperate from JAXB.  It's a pretty quick implementation,
>> and only does what I need it to do.  It depends on the JSON objects
>> from, which are also included in Jettison under a different
>> package.  The annotations can be used alongside JAXB like so:
>> @XmlRootElement(name = "response")
>> @JsonObject
>> public class MyResponse {
>>  @XmlAttribute
>>  @JsonField
>>  private boolean success;
>>  @XmlElement(name = "msg")
>>  @JsonField(name = "msg")
>>  private String message;
>>  @XmlElementWrapper(name = "errors")
>>  @XmlElement(name = "error")
>>  @JsonField(name = "errors", required = true)  private List<String>
>> errors;  ...
>> }

Would you be interested in updating the existing CXF JSONProvider (the one based on Jettison)
for it to support @JsonObject/etc 
annotations ? I was about to do it myself but given my JSON experience (not great so to say)
I thought I would ping you first :-) we 
can introduce a new package, org.apache.cxf.jaxrs.providers.json, or org.apache.cxf.jaxrs.ext.json,
and add these annotations there, 
and then rely on the fact Jettison ships JSonObject/etc...

cheers, Sergey

>> This will produce this JSON:
>> {success: true, msg: "Test Message", errors: ["a", "b"]}
>> And this XML:
>> <response success="true"><msg>Test
>> Message</msg><errors><error>a</error><error>b</error></errors></respo
>> nse>
>> Since this was written only for personal use, it's a fair bit aways
>> from being a full-featured library.  Stuff that needs to be done
>> before public
>> consumption:
>> 1) Two-way serialization.  Currently it's only bean -> JSON but not
>> the other way around.
>> 2) Reflection caching.  Currently all reflection happens in the
>> middle of serialization.  Breaking it up into reflection +
>> serialization phases as JAXB does it would speed things up considerably.
>> 3) Ability to switch between field/method accessors (currently it
>> only reads
>> fields)
>> As well as some features that could be really useful such as:
>> 1) Pluggable annotation adapters that can be used to read directly
>> from JAXB annotations
>> 2) Type adapters that will allow custom marshalling/unmarshalling,
>> although this could also be done via getters/setters
>> What's the interest level in putting something like this into CXF?
>> Cheers,
>> Gary

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to
waive confidentiality or privilege. Use of 
this email is prohibited when received in error. 

View raw message