Hi
On 10/10/12 10:47, sireesh wrote:
Hi,

I'm using org.apache.cxf.jaxrs.provider.JSONProvider to marshal my REST
responses into JSON.
I've date(javax.xml.datatype.XMLGregorianCalendar) property, which needs to
be marshalled into a Microsoft specific date format.

Can someone please let me know if there is anyway I can plugin
CustomConverter for a specific class,
so that I can customize JSON marshalling.

I could find only org.codehaus.jettison.mapped.TypeConverter to be plugged.
But this converter is being
invoked for all the marshalled JSON properties and it's hard to tell the
type of the property from the received text.


Can you get a JAXB plugin generating the property with a different type ? If that does not work a more involved option is to register a custom XMLStreamWriter on the outbound message which will handle this specific property as needed - it is still easy enough to do, it can extend the CXF utility writer and then it has to be registered from a response filter on the outbound message, or JSONProvider can be extended to get this custom writer returned.

Cheers, Sergey



Kiran Sireesh




--
View this message in context: 
http://cxf.547215.n5.nabble.com/Plugin-custom-converter-for-Java-object-in-CXF-JSONProvider-tp5716245.html
Sent from the cxf-user mailing list archive at Nabble.com.


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to