• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to implement a custom serializer for jersey

 
Geoffry Colin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

I am implementing a REST call that must return either JSON or XML.  I am using the jetty, jersey, jackson stack.  The JSON part is in hand, but the XML bit requires custom serialization.  My pojos are generated code so clearly, annotations are not wise and therefore, the default JAXB based serialization is out of the question.  I have been reading about jersey's dependency injection capabilities but I can't get clear on how to use them to solve my problem. 

I know how to implement a serialization to XML that respects my generated code.  How do I get jersey to call it instead of the defaults?  That's my question.

Thanks in advance
 
Stephan van Hulst
Bartender
Posts: 6586
85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably much easier to write some data transfer objects and describe their XML format with annotations. Then you convert your generated objects to data transfer objects and serialize those.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!