Questions tagged [xstream]

XStream is a simple Java library to serialize objects to XML and back again.

XStream

XStream is a simple library to serialize objects to XML and back again. It is typical used for Transport, Persistence, Configuration and Unit Tests.

Features

  • Ease of use. A high level facade is supplied that simplifies common use cases.

  • No mappings required. Most objects can be serialized without need for specifying mappings.

  • Performance. Speed and low memory footprint are a crucial part of the design, making it suitable for large object graphs or systems with high message throughput.

  • Clean XML. No information is duplicated that can be obtained via reflection. This results in XML that is 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 are not required to have default constructor.

  • Full object graph support. Duplicate references encountered in the object-model will be maintained. Supports circular references.

  • Integrates with other XML APIs. By implementing an interface, XStream can serialize directly to/from any tree structure (not just XML).

  • Customizable conversion strategies. Strategies can be registered allowing customization of how particular types are represented as XML.

  • Error messages. When an exception occurs due to malformed XML, detailed diagnostics are 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.

References

1024 questions
39
votes
4 answers

Security framework of XStream not initialized, XStream is probably vulnerable

Security framework of XStream not initialized, XStream is probably vulnerable I keep getting this console error in red while using XStream (1.4.10) I tried the…
Georgian
  • 8,795
  • 8
  • 46
  • 87
33
votes
5 answers

how to create an InputStream from a Document or Node

How can I create an InputStream object from a XML Document or Node object to be used in xstream? I need to replace the ??? with some meaningful code. Thanks. Document doc = getDocument(); InputStream is = ???; MyObject obj = (MyObject)…
Mike Pone
  • 18,705
  • 13
  • 53
  • 68
22
votes
6 answers

How to disable pretty-printing(white space/newline) in XStream?

This is how I create XStream instance for XML: XStream xstream = new XStream(); This is for JSON: private final XStream xstream = new XStream(new JsonHierarchicalStreamDriver() { public HierarchicalStreamWriter createWriter(Writer writer)…
IgorM
  • 1,068
  • 2
  • 18
  • 29
22
votes
5 answers

How to make XStream skip unmapped tags when parsing XML?

I have a large XML document that I want to convert to a Java bean. It has a lot of tags and attributes, but I'm interested only in a handful of those. Unfurtounately, it seems that XStream forces you to declare a property in that bean for each and…
Fixpoint
  • 9,619
  • 17
  • 59
  • 78
21
votes
5 answers

XStream and underscores

It looks like XStream (com.thoughtworks.xstream -> xstream 1.4.2) is handling underscores in element and attribute names in a very strange way. I need to fetch and parse an xml from a customer that are having underscores in their attributes. This is…
eigil
  • 1,172
  • 2
  • 12
  • 23
20
votes
6 answers

com.thoughtworks.xstream.security.ForbiddenClassException

I came across this exception while updating xstream (1.4.8) lib to the latest version in one of our web applications. The exception was being thrown in a pojo from a dependent jar that was compiled using an older version of xstream (1.3.1). I…
karthik
  • 295
  • 1
  • 5
  • 13
18
votes
4 answers

XStream : node with attributes and text node?

I would like to serialize an object to an XML of this form with XStream. text The value of the node (text) is a field on the serialized object, as well as the att attribute. Is this possible without writing a converter for…
subb
  • 1,578
  • 1
  • 15
  • 27
16
votes
6 answers

Modern alternative to Java XStream library?

I used XStream many years ago, but I see that the libraries is not updated since 2008 (latest news). Is there now a more modern and up to dates Java XML serialization library?
Eli Schneider
  • 4,903
  • 3
  • 28
  • 50
16
votes
3 answers

Parsing XML with references to previous tags, and with children corresponding to subtypes of some class

I have to deal with (a variation of) the following scenario. My model classes are: class Car { String brand; Engine engine; } abstract class Engine { } class V12Engine extends Engine { int horsePowers; } class V6Engine extends Engine…
aioobe
  • 413,195
  • 112
  • 811
  • 826
14
votes
4 answers

Xstream no-args constructor error

I'm getting the following error when it tries to create an instance of 'Transacao' `Error: Cannot construct br.com.cbmp.ecommerce.resposta.Transacao as it does not have a no-args constructor : Cannot construct…
luishenrique.ln
  • 175
  • 1
  • 2
  • 7
14
votes
5 answers

Xstream: removing class attribute

How do I remove the class=”Something ” attributes in Xstream . I use Xstream with annotations
Quintin Par
  • 15,862
  • 27
  • 93
  • 146
14
votes
3 answers

How do I encode UTF-8 using the XStream framework?

Per XStream's FAQ its default parser does not preserve UTF-8 document encoding, and one must provide their own encoder. How does one do this? Thanks!
user118805
13
votes
3 answers

How to convert List of Object to XML doc using XStream

How to convert List of Object to XML doc using XStream ? and how to deserialize it back ? This is my xml Guilherme 10
NewBeee_Java
12
votes
6 answers

Java XStream - Ignore tag that doesn't exist in XML

I currently use a piece of XML like the following Frank Smith 100023412 12/05/1954 01/09/2010 Windows // Wild card that may occasionally…
Qwan
  • 157
  • 1
  • 6
12
votes
2 answers

using RESTlet, XStream annotations seem to have no effect

Using @XStreamOmitField in my POJO seems to have no effect whatsoever. the annotated field still gets exposed in the xml or json representation. @XStreamAlias("Pojo") @Entity public class Pojo { private String name; @Id …
chaos0815
  • 811
  • 16
  • 27
1
2 3
68 69