XStream
  1. XStream
  2. XSTR-403

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

      }

        People

        • Assignee:
          Unassigned
          Reporter:
          Adam Lister
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: