code: protected String recurse(Object input)
              throws IOException {
          increaseDepth();
          if (depth > MAXIMUMDEPTH) {
              decreaseDepth();
              return "{ \"error\": \"maximum serialization-depth reached.\" }";
          }
          StringWriter writer = new StringWriter();
          mapper.writeValue(writer, input);
          writer.close();
          decreaseDepth();
          return writer.getBuffer().toString();
      }
docs: This method should only be used by serializers who need recursive calls. It prevents overflow due to circular
  references and ensures that the maximum depth of different sub-parts is limited
  
  @param input the object to serialize
  @return the jsonserialization of the given object
  @throws java.io.IOException If serialisation of the object failed.