code: public static void writeJson(Writer writer, Object object) throws IOException {
      ObjectMapper om = ObjectMapperProvider.createCustomMapper();
  
      om.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
      om.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
  
      writer.write(om.writeValueAsString(object));
      writer.write("\n");
      writer.flush();
    }
docs: Writes object to the writer as JSON using Jackson and adds a new-line before flushing.
  @param writer the writer to write the JSON to
  @param object the object to write as JSON
  @throws IOException if the object can't be serialized as JSON or written to the writer