Details
Description
Executing the following unit test against the svn trunk produces an assertion error and prints the json:
{"tree-map":
,"entry":{"string":["a","b"]}}
It seems the "entry" element should be part of the "tree-map" element, rather than at the top level
public void testTreeMap()
{ TreeMap map = new TreeMap(); map.put("a", "b"); XStream xstream = new XStream(new JettisonMappedXmlDriver()); String json = xstream.toXML(map); System.out.println(json); Object o = xstream.fromXML(json); assertEquals(map, o); }Issue Links
- is related to
-
XSTR-576 Remove <no-comparator/> tag from TreeMap and TreeSet output.
com.thoughtworks.xstream.converters.collections.TreeMapConverter:73
a TreeMap with a comparator will be successfully serialized and de-serialized.
Seems like the problem is either in PathTrackingWriter or jettison itself.
For the moment two usable work-arounds exist:
1 - Ensure all TreeMap's being serialized have comparators
2 - Write our own TreeMapConverter to either set the comparator at serialization, or ignore null comparators (which requires changes to deserialization)