code: public static SimpleModule getModule(final ObjectMapper mapper) {
          SimpleModule module = new SimpleModule();
          module.setSerializerModifier(new BeanSerializerModifier() {
              @Override
              public JsonSerializer<?> modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer<?> serializer) {
                  for (Class<?> c : TypeUtil.getAllClasses(beanDesc.getBeanClass())) {
                      if (c.isAssignableFrom(Object.class)) {
                          continue;
                      }
                      Field[] fields = c.getDeclaredFields();
                      for (Field field : fields) {
                          if ("additionalProperties".equalsIgnoreCase(field.getName())) {
                              JsonProperty property = field.getAnnotation(JsonProperty.class);
                              if (property != null && property.value().isEmpty()) {
                                  return new AdditionalPropertiesSerializer(beanDesc.getBeanClass(), serializer, mapper);
                              }
                          }
                      }
                  }
                  return serializer;
              }
          });
          return module;
      }
docs: Gets a module wrapping this serializer as an adapter for the Jackson
  ObjectMapper.
  
  @param mapper the object mapper for default serializations
  @return a simple module to be plugged onto Jackson ObjectMapper.