我想利用XStream将java的 has变成一个json的 has。 我认为,这比似乎更容易。 我期望的是:
Map<String, String> map = new HashMap<String, String>();
map.put("first", "value1");
map.put("second", "value2");
加入
{ first : value1 , second : value2 }
The closes I have converts it into a series of arrays.
XStream xstream = new XStream(new JettisonMappedXmlDriver() {
public HierarchicalStreamWriter createWriter(Writer writer) {
return new JsonWriter(writer, JsonWriter.DROP_ROOT_MODE);
}
});
xstream.toXML(map);
which 加入s
[["first", "value1"], ["second", "value2"]]
我认为,把一个 j瓦的 has变成一个son,应该直截了当。 我失踪了吗?