Details
Description
I've attempted to serialize several classes with the Collection interface as an attribute. It appears that this produces an invalid JSON string. Here's an example of the output I'm getting:
{"TestCollection":
{ "strings": [ "class" :"list"" "String1" ] }}Notice the extra quote after list, for example. Also, here is the code I'm using to produce this output.
import java.util.ArrayList;
import java.util.Collection;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver;
public class TestCollection {
private Collection strings;
public Collection getStrings()
public void setStrings(Collection strings)
{ this.strings = strings; }public static void main(String[] args)
{ TestCollection test = new TestCollection(); ArrayList strings = new ArrayList(); strings.add("String1"); test.setStrings(strings); XStream xs = new XStream(new JsonHierarchicalStreamDriver()); String xml = xs.toXML(test); System.out.println(xml); }}
This is fixed now in the head revision. You may give it a try.