xstream

XStream serializable objects

I am currently using XStream to serialize some of my objects that don't implement Serializable. Is there a way to tell XStream to use Java's default serialization if the object does implement Serializable and to fall back on XML serialization if it does not? Or would I need to implement a simple layer on top of it to check? thanks, Jeff...

Using XStream to deserialize an XML response with separate "success" and "failure" forms?

I am planning on using XStream with Java to convert between objects and XML requests and XML responses and objects, where the XML is flowing over HTTP/HTTPS. On the response side, I can get a "successful" response, which seems like it would map to one Java class, or a "failure" response, which seems like it would map to another Java clas...

Xstream giving different results

We are using XStream for our restful services. However, Xstream gives us varying results for fields with the same values. assume it Book object: public class Book{ public String name "myName"; public Listauthors = new List(); public String subject "mySubject"; public Book(){ } } The json for this is: {"Book":{"name":"myName", "a...

C++ Serialization Clean XML Similar to XSTREAM

I need to write a linux c++ app which saves it settings in XML format (for easy hand editing) and also communicates with existing apps through XML messages over sockets and HTTP. Problem is that I haven't been able to find any intelligent libs to help me, I don't particular feel like writing DOM or SAX code just to write and read some ve...

How can I disable unnecessary escaping in XStream?

XStream by default unnecessarily escapes >," ... etc. Is there a way to disable this (and only escape <, &)? ...

Basic XStream Annotations

Hello, I just started using XStream Annotations, and I am trying to figure out how to associate the annotations with the XStream object. From the documentation, it seems like this is the accepted method: XStream xstream = new XStream(new DomDriver()); xstream.processAnnotations(AnnotatedClass.class); My problem with this is that Ecl...

xstream and ibm j9 sdk incompatibilities on linux

I encountered an incompatibility with xstream and IBM J9 jdk (the 32bits version). Everything worked fine when I used sun jdk but fails on IBM jdk (on linux only. on windows it's ok with both jdks). When debugging, the error appears to be that xstream uses a java.util.TreeSet internally but the set's iterator returns elements in the wro...

Deserializing XML text elements with attributes in XStream

Basically, I want to do the reverse of this question. I'm getting XML from Microsoft's Bing batch Geocode service, and some of the elements look like this (poached from here): <DataflowJob> <Id>5bf10c37df944083b1879fbb0556e67e</Id> <Link role="self">https://spatial.virtualearth.net /REST/v1/dataflows/Geocode/5bf10c37df944083b18...

XStream - Root as a collection of objects.

I'm consuming an XML payload that looks something like this (for a more comprehensive example, check out : http://api.shopify.com/product.html ). <products type="array"> <product> ... </product> <product> ... </product> </products> Now currently my code does work, but its doing something that appears to be real...

Serializing Java objects to XML with XStream

The problem is that every time I execute the main method, the old content of a.xml is lost and is substituted with a new one. How to append content to the a.xml file without losing the previous information? import java.io.FileNotFoundException; import java.io.PrintWriter; import com.thoughtworks.xstream.XStream; import com.thoughtworks...

Warning from XStream, cannot find itemFieldName in XStreamImplicit

I'm trying to track down th source of a warning: warning: Cannot find annotation method 'itemFieldName()' in type 'com.thoughtworks.xstream.annotations.XStreamImplicit' The relevant code is: @XStreamAlias("things") @XStreamImplicit(itemFieldName = "things") private List<Thing> things; Looking at the XStream JAR I see: @java.lang.a...

Generic Collections and XStream

Is there a way to map (using xstream) a List<Person> to <friends> and List<Things> to <stuff> for example? Thanks! ...

Hi, I would like to (de)serialize an object(Hashmap) from an XML of this form with XStream.

XML: JAVA Hashmap: map = {key1=text1,key2=text2} this doesn't work. why? String xml = "<nodes><node id=\"key1\"><![CDATA[text1]]></node><node id="\key2\"><![CDATA[text2]]></node></nodes>"; XStream xs = new XStream(); xs.alias("nodes", Map.class); xs.alias("node", String.class); xs.useAttributeFor("id",String.class); Map<String,St...

xstream flatten an object

Hello, I am trying to flatten the xml output of xstream using a converter/marshaling with no luck. For example, public class A{ public B b; public int F; public String G; } public class B{ public String C; public String D; public int E; } is output as <A> <B> <C></C> <D></D> <E></E> </B> ...

How can I get rid of the class attribute and perform my own conversion using XStream?

First of all I have read link text and it does not solve my problem. I am using XStream with aliasing. Condition is an interface with several different implementations. I want to remove the class attribute. I know that XStream uses the class attribute when it the implementing class is ambiguous and I can setup an alias for at most one ...

How to attach a XStream converter just for a certain element?

It is easy to set a converter for a certain type (http://xstream.codehaus.org/javadoc/com/thoughtworks/xstream/XStream.html gives an example): xstream.registerConverter(new SqlTimestampConverter()); xstream.registerConverter(new DynamicProxyConverter()); I would like to register a converter, but on different element names. The Convert...

How do I use StAX instead of XPP for XStream?

I want to use a fast pull parser for XStream's reading, but the default pull parser from Java 6. (Not DOM!) What do I have to do? ...

How to easy serialize an xml file in objects with XStream library

I have the below xml file: <?xml version="1.0" encoding="UTF-8"?> <!-- This is a sample netbeans project file for a Squawk project. You may edit it freely, it doesn't affect the ant-powered build. --> <project xmlns="http://www.netbeans.org/ns/project/1"&gt; <type>org.netbeans.modules.ant.freeform</type> <configur...

How-to handle legacy classes with Xstream?

API publisher added new field to their response object that isn't in my model classes. Is there a way to loosen up the mapper to ignore unknown fields? I still want to use my old legacy model classes to parse, but now I get an exception... ...

Can XStream handle complex objects without any extra work?

Hello, I'm thinking of using the XStream library but I have a couple of questions/concerns. Say I have a complex object that I want to serialize into XML (or JSON) using XStream. Is XStream able to handle this without any extra work? For example: class Foo { private Bar bar; private string name; // Getters and Setters }...