This is how I create XStream instance for XML:
XStream xstream = new XStream();
This is for JSON:
private final XStream xstream = new XStream(new JsonHierarchicalStreamDriver() {
public HierarchicalStreamWriter createWriter(Writer writer) {
return new JsonWriter(writer, JsonWriter.DROP_ROOT_MODE);
}
});
Both of them are pretty-printing (indenting) the output.
How can I ask the XStream to disable the pretty printing?