History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-403
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: Adam Lister
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XStream

JsonHierarchicalStreamDriver not serializing Collections correctly

Created: 31/May/07 09:51 AM   Updated: 25/Feb/08 05:01 PM
Component/s: Core
Affects Version/s: 1.2.1, 1.2.2
Fix Version/s: 1.3

JDK version and platform: Sun 1.4.2


 Description  « Hide
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() {
return strings;
}
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);
}
}

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Joerg Schaible - 30/Nov/07 10:22 PM
This is fixed now in the head revision. You may give it a try.

Joerg Schaible - 25/Feb/08 05:01 PM
Closing issues before next release.