JsonGenerator jgen = new JsonFactory(mapper()).createGenerator(sw);
if (prettyPrint) {
jgen.setPrettyPrinter(new DefaultPrettyPrinter());
}
if (escapeNonASCII) {
jgen.enable(Feature.ESCAPE_NON_ASCII);
}
mapper().writeValue(jgen, o);
sw.flush();
return sw.toString();
} catch (IOException e) {