Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB is good until I need to do something complex. What are the alternatives?

Tags:

java

xml

jaxb

JAXB works well until I need to do something like serialize beans for which I cannot modify the source. If the bean doesn't have a default constructor or if it refers to objects I want to mark transient then I'm stuck writing a separate bean which I can annotate and then manually copy the information over from the other bean.

For instance, I wanted to serialize exception objects, but found that the only way to do that was use a hack that required using com.sun.* classes.

So, what alternatives are there? What's the next most popular xml serializing api? It would be nice to be able to do things like:

  • Choose at serialization time whether to include certain fields in the result. (marking things transient when running the serializer).

  • Handle loops in the object graph by using references or something other than just dying.

  • Perhaps annotate an object so that in version 1 it serializes things in one way and in version 2 it serializes them in another. Then when serializing I just choose which version of the object ot serialize.

  • Have a way to generate XSDs from annotations on an object.

Basically I just want more flexibility than I currently have with JAXB.

like image 779
HappyEngineer Avatar asked Aug 13 '09 21:08

HappyEngineer


1 Answers

Well the standard answer for wanting a uber configurable serialisation framework is xstream.

like image 146
Gareth Davis Avatar answered Oct 04 '22 20:10

Gareth Davis