XStream

JsonHierarchicalStreamDriver not serializing Collections correctly

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Resolution: Fixed
  • Affects Version/s: 1.2.1, 1.2.2
  • Fix Version/s: 1.3
  • Component/s: Core
  • Labels:
    None
  • JDK version and platform:
    Sun 1.4.2

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() { 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); }
}

Activity

Hide
Joerg Schaible added a comment -

This is fixed now in the head revision. You may give it a try.

Show
Joerg Schaible added a comment - This is fixed now in the head revision. You may give it a try.
Hide
Joerg Schaible added a comment -

Closing issues before next release.

Show
Joerg Schaible added a comment - Closing issues before next release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: