customising serialisation of java collections using xstream

Posted by Will Goring on Stack Overflow See other posts from Stack Overflow or by Will Goring
Published on 2009-11-24T16:24:49Z Indexed on 2010/05/13 8:14 UTC
Read the original article Hit count: 278

I have an object that needs to be serialised as XML, which contains the following field:

List<String> tags = new List<String>();

XStream serialises it just fine (after some aliases) like this:

<tags>
  <string>tagOne</string>
  <string>tagTwo</string>
  <string>tagThree</string>
  <string>tagFour</string>
</tags>

That's OK as far as it goes, but I'd like to be able to rename the <string> elements to, say, <tag>. I can't see an obvious way to do that from the alias documentation on the XStream site. Am I missing something obvious?

© Stack Overflow or respective owner

Related posts about java

Related posts about xstream