JsonFactory factory = new JsonFactory();
JsonGenerator generator = factory.createJsonGenerator(out);
ObjectMapper mapper = getMapper();
mapper.setSerializationInclusion(Inclusion.NON_NULL);
generator.setCodec(mapper);
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
Indenter indenter = new Lf2SpacesIndenter();
prettyPrinter.indentArraysWith(indenter);
generator.setPrettyPrinter(prettyPrinter);
generator.writeObject(object);
writeEndingMsgToScreen(fileName);
} finally {
if (out != null && !(out instanceof PrintStream)) {