tags:

views:

51

answers:

2

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
}


class Bar
{
    private Integer id;
    private string name;

    // getters and setters
}

Can XStream handle this correctly? Thanks!

+3  A: 

Short answer: Yes, it can.

But will do it with a lot of reflection overhead. I wouldn't write such code in production release. Also, keep in mind that you have to look for bi-directional reference which will cause a runtime exception.

Bivas
+1  A: 

Yes, simple nested structures (references to other objects, lists and maps) are supported.

Things get hairy if you need to access fields from different levels (say, you need an attribute from <foo> in Bar).

Aaron Digulla