if (null == out)
throw new NullPointerException("OutputStream cannot be null");
JsonGenerator g
= new JsonFactory().createJsonGenerator(out, JsonEncoding.UTF8);
if (pretty) {
DefaultPrettyPrinter pp = new DefaultPrettyPrinter() {
//@Override
public void writeRootValueSeparator(JsonGenerator jg)
throws IOException
{
jg.writeRaw(LINE_SEPARATOR);
}
};
g.setPrettyPrinter(pp);
} else {
MinimalPrettyPrinter pp = new MinimalPrettyPrinter();
pp.setRootValueSeparator(LINE_SEPARATOR);
g.setPrettyPrinter(pp);
}
return g;
}