Details
-
Type: Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.1.1
-
Component/s: None
-
Labels:None
-
JDK version and platform:Sun JDK 1.5 for Windows
Description
First off this is a really cool API. Keep up the great work guys!
The bug that I've encountered is when you have the following structure:
public class Foo {
public Fum fum;
public Foo()
{ fum = new Fum(); }}
// and:
public class Fum {
public String s;
public Fum()
{ s = "test"; }}
When I do the following:
Foo f = new Foo();
XStream xstream = new XStream();
xstream.alias("Foo", Foo.class); // <- this one is honored
xstream.alias("Fum", Fum.class); // <- this one is not honored
The following document is created:
<Foo>
<fum>
<string>test</string>
</fum>
</Foo>
Fum should be uppercase but is left as lower case. I attempted to find where this change is made in code but I don't know the source code very well so I wasn't exactly sure where to look for that.
I'm using the latest but I also tried with 1.1. They are all in the same package (not the default anonymous package) if that helps.
Thanks,
Arron
Hi Arron,
I believe this is a misunderstanding in how the class aliasing works - when you create an alias, it is for a class, not a field.
Otherwise, with your aliases, it would be impossible to deserialize an object that looked like this:
class Foo
{ Fum oneFum; Fum twoFum; }One of the features of the next release will be allowing you to map aliases to fields as well as classes, which should enable you to do what you want. You will be able to do something like this (but not until 1.1.1):
xstream.alias("Foo", Foo.class); // alias Foo class as 'Foo'
xstream.alias("Fum", Foo.class, "fum"); // alias Foo.fum fields as 'Fum'