mbx
mbx

Reputation: 6526

Best Practice for Serialize/Deserialize from Java to XML

What is the most appropriate way to serialize Java Classes to XML? I tried JAXB, but it has issues with Interfaces and Generics. What solution is least intrusive but scalable?

Upvotes: 7

Views: 2384

Answers (2)

laher
laher

Reputation: 9110

I've always had positive experiences with XStream:

http://x-stream.github.io/tutorial.html#to-xml

As you can see, it's simple to use.

I haven't actually used XStream with Generics (I've only ever used it for simple JavaBean type classes), but Google seems to suggest it handles them without problems. e.g. http://techo-ecco.com/blog/xstream-spring-ws-oxm-and-generics/

Upvotes: 4

stacker
stacker

Reputation: 68942

I would suggest to overcome the issues with interfaces and generics you have with JAXB.

JAXB Marshalling and Generics

java.util.List is an interface, and JAXB can't handle interfaces

Upvotes: 1

Related Questions