This feature as useful as it is, breaks parsing of maps in apps using older versions. For better backward compatibility, it should be made optional as proposed by attached patch.
thanks for your response. I mean that XStream upgrade to 1.3.1 (which includes this change for use of serializeAsArray for maps) breaks how maps were working with earlier version.
For example, after upgrade of ActiveMQ to use Jettison 1.2 and XStream 1.3.1 we have
properly converted to map and sent to the broker. But when it comes back, it's unmarshalled like
Some users prefer the first format as it seems more natural representation of maps.
I am not sure if this patch is a wise move. I ran the unit tests against the "new" format and I recognized why the serializeAsArray stuff was added in first place: A list with a single element is then no longer serialized as list in JSON i.e. the representation of a list in JSON differes on the number of elements. I am not keen on getting all the complaints about this behavior again.
Additionally, since you mentioned the map, I don't think that the XStream's MapConverter is the best choice when you marshal to JSON. In this case I'd use one that renders the keys as tags (resp. labels) anyway. When you surround the label with quotes, you can use quite anything as label and you're not limited to valid XML tags.
Hi Dejan, are you still interested in this change despite the consequences I've lined out in the last comment?
I'm interested in this unless we can find another workaround for it (and I'd like to keep the same, or similar, code when converting to XML and JSON).
I don't think this change will break things as it keeps current functionality by default. It just enable users to configure it the other way if they want it.
Hmm. Which older version do you mean? XStream or Jettison? IMHO you cannot compare output Jettison 1.2 and 1.0.x anyway, I had to adjust the JSON structure in the unit tests to make XStream compatible for 1.2: http://svn.xstream.codehaus.org/browse/xstream/trunk/xstream/src/test/com/thoughtworks/xstream/io/json/JettisonMappedXmlDriverTest.java?r2=1727&r1=1641