
| Key: |
XSTR-403
|
| Type: |
Bug
|
| Status: |
Closed
|
| Resolution: |
Fixed
|
| Assignee: |
Unassigned
|
| Reporter: |
Adam Lister
|
| Votes: |
0
|
| Watchers: |
0
|
|
If you were logged in you would be able to see more operations.
|
|
|
XStream
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
|
|
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);
}
}
|
|
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);
}
} |
Show » |
|