XStream is a simple library to serialize objects to XML and back again.
Features
- Ease of use. A High level facade are supplied that simplifies common use cases.
- No mappings required. Most objects can is serialized without need for specifying mappings.
- performance. Speed and low memory footprint is a crucial part of the design, making it suitable for large object graphs or system s with high message throughput.
- Clean XML. No information is duplicated this can be obtained via reflection. This results in XML, easier to read for humans and more compact than native Java serialization.
- Requires no modifications to objects. serializes internal fields, including private and final. Supports Non-public and inner classes. Classes is required to has the default constructor.
- Full object graph support. Duplicate references encountered in the Object-model would be maintained. Supports circular references.
- integrates with other XML APIs. by implementing a interface, XStream can serialize directly to/from any tree structure (not just XML).
- customizable conversion strategies. strategies can registered allowing customization of how particular types is represented as XML.
- Security Framework. Fine-control about the unmarshalled types to prevent security issues with manipulated input.
- Error messages. When a exception occurs due to malformed XML, detailed diagnostics is provided to help isolate and fix the problem.
- alternative output format. The modular design allows other output formats. XStream ships currently with JSON support and morphing.
Typical Uses
- Transport
- Persistence
- Configuration
- Unit Tests
Known Limitations
If using the enhanced mode, XStream can re-instantiate classes that does not have a default constructor. However, if using a different JVM like an old JRockit version, a JDK 1.4 or you have restrictions because of a securityman Ager, a default constructor is required.
The enhanced mode is also necessary to restore final fields for any JDK < 1.5. This implies deserialization of instances of a inner class.
Auto-detection of annotations may cause race conditions. Preprocessing annotations is safe though.
Tutorials
- Minute Tutorial
- Alias Tutorial
- Annotations Tutorial
- Converter Tutorial
- Object Streams Tutorial
- Persistence API Tutorial
- JSON Tutorial